public static <T> List<List<InferenceGraphNode<T>>> tarjan(Collection<? extends InferenceGraphNode<T>> nodes, int limit) {
    final ArrayList<List<InferenceGraphNode<T>>> result = new ArrayList<>();
    final Stack<InferenceGraphNode<T>> currentStack = new Stack<>();
    int index = 0;
    for (InferenceGraphNode<T> node : nodes) {
      if (node.index == -1) {
        index += InferenceGraphNode.strongConnect(node, index, currentStack, result);
        if (result.size() >= limit) break;
      }
    }
    return result;
  }
public static <T> List<List<InferenceGraphNode<T>>> tarjan(Collection<? extends InferenceGraphNode<T>> nodes, int limit)