public static <NodeType> Collection<NodeType> collectNodes(
      final Collection<? extends NodeType> nodes, final INodeFilter<NodeType> filter) {
    Preconditions.checkNotNull(nodes, "Error: Nodes argument can't be null");
    Preconditions.checkNotNull(filter, "Error: Filter argument can't be null");

    final Collection<NodeType> filteredNodes = new ArrayList<NodeType>();

    for (final NodeType child : nodes) {
      // Don't bother to re-select the nodes that are already selected
      if (filter.qualifies(child)) {
        filteredNodes.add(child);
      }
    }

    return filteredNodes;
  }
Filters all nodes from a list of nodes that pass a filter check.

@param <NodeType> The type of nodes in the list.
@param nodes The unfiltered list of nodes.
@param filter The filter that provides the node check.
@return All nodes that pass the filter check.
java/zylib/src/main/java/com/google/security/zynamics/zylib/types/graphs/GraphAlgorithms.java