def equals(self, other, cache=None):
    if (cache is None):
        cache = {}
    key = (self, other)
    try:
        return cache[key]
    except KeyError:
        cache[key] = result = ((self is other) or ((type(self) == type(other)) and all_equal(self.args, other.args, cache=cache)))
        return result
def equals(self, other, cache=None):
    if (cache is None):
        cache = {}
    key = (self, other)
    try:
        return cache[key]
    except KeyError:
        cache[key] = result = ((self is other) or ((type(self) == type(other)) and all_equal(self.args, other.args, cache=cache)))
        return result