code: private <T extends ImmutableTerm> ImmutableSubstitution<T> extractDescendingSubstitution(
              ImmutableSubstitution<? extends NonFunctionalTerm> substitution,
              java.util.function.Function<NonFunctionalTerm, T> valueTransformationFct,
              ImmutableSubstitution<? extends ImmutableTerm> partialTheta,
              ImmutableSubstitution<? extends ImmutableTerm> newPartialTheta,
              ImmutableSet<Variable> originalProjectedVariables) {
  
          return substitutionFactory.getSubstitution(
                  substitution.getImmutableMap().entrySet().stream()
                          .filter(e -> {
                              Variable v = e.getKey();
                              return (!partialTheta.isDefining(v))
                                      && ((!newPartialTheta.isDefining(v)) || originalProjectedVariables.contains(v));
                          })
                          .collect(ImmutableCollectors.toMap(
                                 e -> e.getKey(),
                                 e -> valueTransformationFct.apply(e.getValue())
                          )));
      }
docs: TODO: find a better name