'Returns true iff this tag has the same name, the same attributes,
and the same contents (recursively) as the given tag.
NOTE: right now this will return false if two tags have the
same attributes in a different order. Should this be fixed?'

def __eq__(self, other):

    if (other is self):
        return True
    if ((not hasattr(other, 'name')) or (not hasattr(other, 'attrs')) or (not hasattr(other, 'contents')) or (self.name != other.name) or (self.attrs != other.attrs) or (len(self) != len(other))):
        return False
    for i in range(0, len(self.contents)):
        if (self.contents[i] != other.contents[i]):
            return False
    return True
