public static Map<Node, Node> createNodes(Document document, String containerNodeName, String childNodeName, String nodeContent) {
        return asStream(document.getElementsByTagName(containerNodeName))
                .collect(Collectors.toMap(
                        containerNode -> containerNode,
                        containerNode -> {
                            Node childNode = document.createElement(childNodeName);
                            containerNode.appendChild(childNode);
                            if (nodeContent != null) {
                                childNode.setTextContent(nodeContent);
                            }
                            return childNode;
                        }
                ));
    }
@Test
    public void createNodes() throws Exception {
        final String newNodeName = "NEW_NODE_NAME";
        final String newNodeValue = "NEW_NODE_VALUE";
        Document document = DOMParserUtil.getDocument(XML);
        Map<Node, Node> retrieved = DOMParserUtil.createNodes(document, MAIN_NODE, newNodeName, newNodeValue);
        assertThat(retrieved).hasSize(1);
        Node created = (Node) retrieved.values().toArray()[0];
        assertThat(created).isNotNull();
        assertThat(created.getNodeName()).isEqualTo(newNodeName);
        assertThat(created.getTextContent()).isEqualTo(newNodeValue);
        retrieved = DOMParserUtil.createNodes(document, MAIN_NODE, newNodeName, null);
        assertThat(retrieved).hasSize(1);
        created = (Node) retrieved.values().toArray()[0];
        assertThat(created).isNotNull();
        assertThat(created.getNodeName()).isEqualTo(newNodeName);
        assertThat(created.getTextContent()).isEmpty();

        retrieved = DOMParserUtil.createNodes(document, CHILD_NODE, newNodeName, newNodeValue);
        assertThat(retrieved).hasSize(2);
        retrieved.forEach((key, createdNode) -> {
            assertThat(createdNode).isNotNull();
            assertThat(createdNode.getNodeName()).isEqualTo(newNodeName);
            assertThat(createdNode.getTextContent()).isEqualTo(newNodeValue);
        });
        retrieved = DOMParserUtil.createNodes(document, CHILD_NODE, newNodeName, null);
        assertThat(retrieved).hasSize(2);
        retrieved.forEach((key, createdNode) -> {
            assertThat(createdNode).isNotNull();
            assertThat(createdNode.getNodeName()).isEqualTo(newNodeName);
            assertThat(createdNode.getTextContent()).isEmpty();
        });
    }