def replace(self, old, new, variable_set=None, leaf_operation=None):   
self._check_replaceability(old, new)<EOL>replacements = {old.cache_key: new}<EOL>return self.replace_dict(replacements, variable_set=old.variables)<EOL>
Returns this AST but with the AST 'old' replaced with AST 'new' in its subexpressions.