private static <T> InferenceGraphNode<T> merge(final List<? extends InferenceGraphNode<T>> cycle,
                                                   final Collection<? extends InferenceGraphNode<T>> allNodes) {
      assert !cycle.isEmpty();
      final InferenceGraphNode<T> root = cycle.get(0);
      if (cycle.size() > 1) {
        for (int i = 1; i < cycle.size(); i++) {
          final InferenceGraphNode<T> cycleNode = cycle.get(i);

          root.copyFrom(cycleNode);
          root.filterInterCycleDependencies();

          for (InferenceGraphNode<T> node : allNodes) {
            if (node.myDependencies.remove(cycleNode)) {
              node.myDependencies.add(root);
            }
          }
        }
      }
      return root;
    }
private static <T> InferenceGraphNode<T> merge(final List<? extends InferenceGraphNode<T>> cycle,
                                                   final Collection<? extends InferenceGraphNode<T>> allNodes)