code: private void removeCommentNodes(Document doc) {
          List<Node> toRemove = new ArrayList<>();
          NodeList children = doc.getChildNodes();
          for (int cn = 0; cn < children.getLength(); cn++) {
              Node child = children.item(cn);
              if (Node.COMMENT_NODE == child.getNodeType()) {
                  toRemove.add(child);
              }
          }
          for (Node child : toRemove) {
              doc.removeChild(child);
          }
      }
docs: Remove any comment nodes from the doc (only top level).
  <p/>
  This is used to remove copyright headers embedded as comment in the pom.xml files etc.