'Invalidate all caches. You must call this before using this object if you have made changes to the HTML tree'

def invalidate_caches(self):

    self._element_map = None
    self._id_map = None
    self._class_map = None
    self._attrib_map = None
    self._attrib_space_map = None
    self._lang_map = None
    self.map_tag_name = ascii_lower
    if (u'{' in self.root.tag):
        def map_tag_name(x):
            return ascii_lower(x.rpartition(u'}')[2])
        self.map_tag_name = map_tag_name
