'Returns True if the given element matches the simple CSS selector.'

def match(self, e):

    if (not isinstance(e, Element)):
        return False
    if (self.tag not in (e.tag, '*')):
        return False
    if (self.id not in ((e.id or '').lower(), '', None)):
        return False
    if (self.classes.issubset(set(map((lambda s: s.lower()), e.attr.get('class', '').split()))) is False):
        return False
    if (('first-child' in self.pseudo) and (self._first_child(e.parent) != e)):
        return False
    if any(((x.startswith('contains') and (not self._contains(e, x))) for x in self.pseudo)):
        return False
    for (k, v) in self.attributes.items():
        if ((k not in e.attrs) or (not ((v is True) or (re.search(v, e.attrs[k]) is not None)))):
            return False
    return True
