private static void addAllNodes(Node node, List<Node> listOfNodes) {
        if (node != null) {
            listOfNodes.add(node);
            NodeList childNodes = node.getChildNodes();

            List<Node> children = null;

            if (childNodes != null) {
                children = new ArrayList<>();
                for (int i = 0; i < childNodes.getLength(); i++) {
                    children.add(childNodes.item(i));
                }
            }


            if (children != null) {
                for (Node child : children) {
                    addAllNodes(child, listOfNodes);
                }
            }
        }
    }