code: def replace(self, old, new, variable_set=None, leaf_operation=None):   # pylint:disable=unused-argument
          
          self._check_replaceability(old, new)
          replacements = {old.cache_key: new}
          return self.replace_dict(replacements, variable_set=old.variables)
docs: Returns this AST but with the AST 'old' replaced with AST 'new' in its subexpressions.