public static List<InferenceVariable> resolveOrder(List<InferenceVariable> vars,
                                                     Map<InferenceVariable, Set<InferenceVariable>> depMap) {
    if (vars.size() < 2) return vars;
    InferenceVariable result = resolveOrderFast(vars, depMap);
    if (result != null) return Collections.singletonList(result);
    Collection<? extends InferenceGraphNode<InferenceVariable>> allNodes = buildInferenceGraph(vars, depMap).values();
    return InferenceGraphNode.merge(tarjan(allNodes, 1).get(0), allNodes).getValue();
  }
public static List<InferenceVariable> resolveOrder(List<InferenceVariable> vars,
                                                     Map<InferenceVariable, Set<InferenceVariable>> depMap)