private static @NotNull Map<InferenceVariable, InferenceGraphNode<InferenceVariable>> buildInferenceGraph(
    Collection<? extends InferenceVariable> vars, Map<InferenceVariable, Set<InferenceVariable>> depMap) {

    Map<InferenceVariable, InferenceGraphNode<InferenceVariable>> nodes = new LinkedHashMap<>(vars.size()*4/3);
    for (InferenceVariable var : vars) {
      nodes.put(var, new InferenceGraphNode<>(var));
    }

    for (Map.Entry<InferenceVariable, InferenceGraphNode<InferenceVariable>> entry : nodes.entrySet()) {
      InferenceVariable var = entry.getKey();
      if (var.getInstantiation() != PsiTypes.nullType()) continue;
      final InferenceGraphNode<InferenceVariable> node = entry.getValue();
      final Set<InferenceVariable> dependencies = depMap.get(var);
      for (InferenceVariable dependentVariable : dependencies) {
        final InferenceGraphNode<InferenceVariable> dependency = nodes.get(dependentVariable);
        if (dependency != null) {
          node.addDependency(dependency);
        }
      }
    }
    return nodes;
  }
private static @NotNull Map<InferenceVariable, InferenceGraphNode<InferenceVariable>> buildInferenceGraph(
    Collection<? extends InferenceVariable> vars, Map<InferenceVariable, Set<InferenceVariable>> depMap)