private void substitute(Term variable, Term replacement, List<UnificationPair> list) {
        for (int i = 0; i < list.size(); i++) {
            // Retrieve the current pair of terms ..
            UnificationPair currentPair = list.get(i);
            Term lhs = currentPair.getLhs();
            Term rhs = currentPair.getRhs();

            // .. and replace that pair with the substitution.
            list.set(i, new UnificationPair(
                    lhs.substitute(variable, replacement),
                    rhs.substitute(variable, replacement)));
        }
    }