private static List<DfaRelation> findDeductionChain(MemoryStateChange change,
                                                      Collection<DfaRelation> knownRelations,
                                                      DfaVariableValue value,
                                                      Relation relation) {
    for (DfaRelation rel : knownRelations) {
      if (isSameRelation(rel, value, relation)) {
        continue;
      }
      for (Map.Entry<DfaVariableValue, TrackingDfaMemoryState.Change> entry : change.myChanges.entrySet()) {
        DfaVariableValue actualVar = entry.getKey();
        for (Relation actualRelation : entry.getValue().myAddedRelations) {
          if (isSameRelation(rel, actualVar, actualRelation)) {
            DfaValue left;
            DfaValue right;
            RelationType type;
            if (actualRelation.myRelationType == RelationType.EQ ||
                (relation.myRelationType != RelationType.NE && relation.myRelationType == actualRelation.myRelationType)) {
              type = relation.myRelationType;
            }
            else if (relation.myRelationType == RelationType.EQ) {
              type = actualRelation.myRelationType;
            }
            else {
              continue;
            }
            if (actualVar == value) {
              left = actualRelation.myCounterpart;
              right = relation.myCounterpart;
            }
            else if (actualVar == relation.myCounterpart) {
              left = value;
              right = actualRelation.myCounterpart;
            }
            else if (actualRelation.myCounterpart == relation.myCounterpart) {
              left = value;
              right = actualVar;
            }
            else if (actualRelation.myCounterpart == value) {
              left = actualVar;
              right = relation.myCounterpart;
            }
            else {
              continue;
            }
            DfaRelation rel1 = DfaRelation.createRelation(left, type, right);
            DfaRelation rel2 = DfaRelation.createRelation(actualVar, actualRelation.myRelationType, actualRelation.myCounterpart);
            return StreamEx.of(rel1, rel2).nonNull().toImmutableList();
          }
        }
      }
    }
    return Collections.emptyList();
  }
private static List<DfaRelation> findDeductionChain(MemoryStateChange change,
                                                      Collection<DfaRelation> knownRelations,
                                                      DfaVariableValue value,
                                                      Relation relation)