code: public void enforceEqualities(CQIE result) {
  
  		List<Function> body = result.getBody();
  		Substitution mgu = new SubstitutionImpl(termFactory);
  
  		// collecting all equalities as substitutions 
  
  		for (int i = 0; i < body.size(); i++) {
  			Function atom = body.get(i);
  			substitutionUtilities.applySubstitution(atom, mgu);
  
              if (atom.getFunctionSymbol() == ExpressionOperation.EQ && ! ((atom.getTerm(0) instanceof Function) && (atom.getTerm(1) instanceof Function)) ) {
                  if (!mgu.composeTerms(atom.getTerm(0), atom.getTerm(1)))
                      continue;
  
                  body.remove(i);
                  i--;
              }
              //search for nested equalities in AND function
              else if (atom.getFunctionSymbol() == ExpressionOperation.AND) {
                  nestedEQSubstitutions(atom, mgu);
  
                  //we remove the function if empty because all its terms were equalities
                  if (atom.getTerms().isEmpty()) {
                      body.remove(i);
                      i--;
                  }
                  else {
                      //if there is only a term left we remove the conjunction
                      if (atom.getTerms().size() == 1) {
                          body.set(i, (Function) atom.getTerm(0));
                      }
                  }
              }
          }
  
  		substitutionUtilities.applySubstitution(result, mgu, false);
  	}
docs: *
  Enforces all equalities in the query, that is, for every equivalence
  class (among variables) defined by a set of equalities, it chooses one
  representative variable and replaces all other variables in the equivalence
  class with the representative variable. For example, if the query body
  is R(x,y,z), x=y, y=z. It will choose x and produce the following body
  R(x,x,x).
  <p>
  We ignore the equalities with disjunctions. For example R(x,y,z), x=y OR y=z
  Note the process will also remove from the body all the equalities that are
  here processed.
  
  
  @param result