public static Node createNodeAtPosition(Node containerNode, String nodeToCreateName, String nodeContent, Integer position) {
        Node toReturn = containerNode.getOwnerDocument().createElement(nodeToCreateName);
        if (nodeContent != null) {
            toReturn.setTextContent(nodeContent);
        }
        if (containerNode.hasChildNodes() && position != null && position < containerNode.getChildNodes().getLength()) {
            Node positionNode = containerNode.getChildNodes().item(position);
            containerNode.insertBefore(toReturn, positionNode);
        } else {
            containerNode.appendChild(toReturn);
        }
        return toReturn;
    }
@Test
    public void createNodeAtPosition() throws Exception {
        String newNodeName = "NEW_NODE_NAME_0";
        String newNodeValue = "NEW_NODE_VALUE_=";
        Document document = DOMParserUtil.getDocument(XML);
        
        Map<Node, List<Node>> testNodesMap = DOMParserUtil.getChildrenNodesMap(document, MAIN_NODE, TEST_NODE);
        assertThat(testNodesMap).hasSize(1);
        
        Node mainNode = testNodesMap.keySet().iterator().next();
        Node retrieved = DOMParserUtil.createNodeAtPosition(mainNode, newNodeName, newNodeValue, null);
        assertThat(retrieved).isNotNull();
        assertThat(retrieved.getNodeName()).isEqualTo(newNodeName);
        assertThat(retrieved.getTextContent()).isEqualTo(newNodeValue);
        assertThat(mainNode.getChildNodes().item(mainNode.getChildNodes().getLength() - 1)).isEqualTo(retrieved);
        
        newNodeName = "NEW_NODE_NAME_1";
        newNodeValue = "NEW_NODE_VALUE_1";
        retrieved = DOMParserUtil.createNodeAtPosition(mainNode, newNodeName, newNodeValue, 0);
        assertThat(retrieved).isNotNull();
        assertThat(retrieved.getNodeName()).isEqualTo(newNodeName);
        assertThat(retrieved.getTextContent()).isEqualTo(newNodeValue);
        assertThat(mainNode.getChildNodes().item(0)).isEqualTo(retrieved);
        
        newNodeName = "NEW_NODE_NAME_2";
        newNodeValue = "NEW_NODE_VALUE_2";
        retrieved = DOMParserUtil.createNodeAtPosition(mainNode, newNodeName, newNodeValue, 2);
        assertThat(retrieved).isNotNull();
        assertThat(retrieved.getNodeName()).isEqualTo(newNodeName);
        assertThat(retrieved.getTextContent()).isEqualTo(newNodeValue);
        assertThat(mainNode.getChildNodes().item(2)).isEqualTo(retrieved);
    }