code: private static boolean applySingletonSubstitution(Function functionalTerm, SingletonSubstitution substitution) {
          List<Term> innerTerms = functionalTerm.getTerms();
          boolean innerchanges = false;
          // TODO this ways of changing inner terms in functions is not
          // optimal, modify
  
          for (int i = 0; i < innerTerms.size(); i++) {
              Term innerTerm = innerTerms.get(i);
  
              if (innerTerm instanceof Function) {
                  // Recursive call
                  innerchanges = innerchanges || applySingletonSubstitution((Function)innerTerm, substitution);
              }
              else if (substitution.getVariable().equals(innerTerm)) { // ROMAN: no need in isEqual(innerTerm, s.getVariable())
                  functionalTerm.getTerms().set(i, substitution.getTerm());
                  innerchanges = true;
              }
          }
          return innerchanges;
      }
docs: May alter the functionalTerm (mutable style)
  
  Recursive