code: public static <T> List<T> select(Iterator<T> iterator, Predicate<T> filter)
     {
        List<T> result = new ArrayList<T>();
        while (iterator.hasNext())
        {
           T element = iterator.next();
           if (filter.accept(element))
           {
              result.add(element);
           }
        }
        return result;
     }
docs: Returns a {@link List} of {@link DependencyNode} objects that satisfy the filter based on the elements returned by
  the {@link Iterator}.
  
  @param iterator An iterator for the {@link DependencyNode} hierarchy tree
  @param filter the {@link DependencyNodeFilter} being used
  @return list of matched elements