public Object visitFunction(Function function, Object arg) { if (null != (substitution = abstractModulation.unifier.unify(toMatch, function))) { if (abstractModulation.isValidMatch(toMatch, toMatchVariables, function, substitution)) { matchingTerm = function; } } if (null == matchingTerm) { // Try the Function's arguments foreach (Term t in function.getArgs()) { // Finish processing if have found a match if (null != matchingTerm) { break; } t.accept(this, null); } } return function; }