Map<EKey, Value> solve() {
    for (Equation equation : equations.values()) {
      queueEquation(equation);
    }
    while (!moving.empty()) {
      EKey id = moving.pop();
      Value value = solved.get(id);

      EKey[] initialPIds = id.stable ? new EKey[]{id, id.invertStability()} : new EKey[]{id.invertStability(), id};
      Value[] initialPVals = id.stable ? new Value[]{value, value} : new Value[]{value, unstableValue};

      EKey[] pIds = new EKey[]{initialPIds[0], initialPIds[1], initialPIds[0].negate(), initialPIds[1].negate()};
      Value[] pVals = new Value[]{initialPVals[0], initialPVals[1], negate(initialPVals[0]), negate(initialPVals[1])};

      for (int i = 0; i < pIds.length; i++) {
        EKey pId = pIds[i];
        Value pVal = pVals[i];
        HashSet<EKey> dIds = dependencies.get(pId);
        if (dIds == null) {
          continue;
        }
        for (EKey dId : dIds) {
          Pending pend = pending.remove(dId);
          if (pend != null) {
            Result pend1 = substitute(pend, pId, pVal);
            if (pend1 instanceof Value) {
              solved.put(dId, (Value)pend1);
              moving.push(dId);
            }
            else {
              pending.put(dId, (Pending)pend1);
            }
          }
        }
      }
    }
    pending.clear();
    return solved;
  }
Map<EKey, Value> solve()