class VisitedDualValues {

  private List<VisitedDualValue> dualValues;

  VisitedDualValues() {
    this.dualValues = new ArrayList<>();
  }

  void registerVisitedDualValue(DualValue dualValue) {
    this.dualValues.add(new VisitedDualValue(dualValue));
  }

  void registerComparisonDifference(DualValue dualValue, ComparisonDifference comparisonDifference) {
    this.dualValues.stream()
                   // register difference on dual values agnostic of location, to take care of values visited several times
                   .filter(visitedDualValue -> visitedDualValue.dualValue.sameValues(dualValue))
                   .findFirst()
                   .ifPresent(visitedDualValue -> visitedDualValue.comparisonDifferences.add(comparisonDifference));
  }

  Optional<List<ComparisonDifference>> registeredComparisonDifferencesOf(DualValue dualValue) {<FILL_FUNCTION_BODY>}

  private static class VisitedDualValue {
    DualValue dualValue;
    List<ComparisonDifference> comparisonDifferences;

    VisitedDualValue(DualValue dualValue) {
      this.dualValue = dualValue;
      this.comparisonDifferences = new ArrayList<>();
    }

    @Override
    public String toString() {
      return format("VisitedDualValue[dualValue=%s, comparisonDifferences=%s]", this.dualValue, this.comparisonDifferences);
    }
  }
}

    return this.dualValues.stream()
                          // use sameValues to get already visited dual values with different location
                          .filter(visitedDualValue -> visitedDualValue.dualValue.sameValues(dualValue))
                          .findFirst()
                          .map(visitedDualValue -> visitedDualValue.comparisonDifferences);
  
<no_super_class>