class DOMParserUtil {

    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;
                        }
                ));
    }

    private  DOMParserUtil();

}