public static <NodeType> boolean any(
      final IIterableGraph<NodeType> graph, final INodeFilter<NodeType> filter) {
    final ArrayList<Object> lameHack = new ArrayList<Object>();

    graph.iterate(
        new INodeCallback<NodeType>() {

          @Override
          public IterationMode next(final NodeType item) {
            if (filter.qualifies(item)) {
              lameHack.add(item);

              return IterationMode.STOP;
            }

            return IterationMode.CONTINUE;
          }
        });

    return lameHack.size() != 0;
  }
This class provides a number of helper functions that are useful when working with graphs.
java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/zygraph/helpers/GraphHelpers.java