code: public static List<DomElement> filterNodeList(NodeList nodeList, NodeListFilter filter) {
  
      List<DomElement> filteredList = new ArrayList<DomElement>();
      for(int i = 0; i< nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if(filter.matches(node)) {
          filteredList.add(new DomElementImpl((Element) node));
        }
      }
  
      return filteredList;
  
    }
docs: Allows to apply a {@link NodeListFilter} to a {@link NodeList}. This allows to remove all elements from a node list which do not match the Filter.
  
  @param nodeList the {@link NodeList} to filter
  @param filter the {@link NodeListFilter} to apply to the {@link NodeList}
  @return the List of all Nodes which match the filter