code: protected Optional<ImmutableMap<Variable, T>> computeUnionMap(ImmutableSubstitution<T> otherSubstitution) {
          ImmutableMap.Builder<Variable, T> mapBuilder = ImmutableMap.builder();
          mapBuilder.putAll(getImmutableMap());
  
          ImmutableMap<Variable, T> otherMap = otherSubstitution.getImmutableMap();
          for(Variable otherVariable : otherMap.keySet()) {
  
              T otherTerm = otherMap.get(otherVariable);
  
              /**
               * TODO: explain
               */
              if (isDefining(otherVariable) && (!get(otherVariable).equals(otherTerm))) {
                  return Optional.empty();
              }
  
              mapBuilder.put(otherVariable, otherTerm);
          }
  
          return Optional.of(mapBuilder.build());
      }
docs: In case some sub-classes wants to add a new unionXX method returning an optional in their own type.
  
  TODO: explain