Return a visitor function that replaces every instance of one expression with another one.

def make_replacement_visitor(find_expression, replace_expression):
    """Return a visitor function that replaces every instance of one expression with another one."""
    def visitor_fn(expression):
        """Return the replacement if this expression matches the expression we're looking for."""
        if expression == find_expression:
            return replace_expression
        else:
            return expression

    return visitor_fn