def METHOD_NAME(self, doc):
    # Get a list of id attributes
    used_ids = set()
    for el in doc.iter():
        if "id" in el.attrib:
            used_ids.add(el.attrib["id"])
    toc_tokens = []
    for el in doc.iter():
        if isinstance(el.tag, str) and self.header_rgx.match(el.tag):
            self.set_level(el)
            text = get_name(el)
            # Do not override pre-existing ids
            if "id" not in el.attrib:
                innertext = unescape(stashedHTML2text(text, self.md))
                el.attrib["id"] = unique(self.slugify(innertext, self.sep), used_ids)  # noqa: E501
            if int(el.tag[-1]) >= self.toc_top and int(el.tag[-1]) <= self.toc_bottom:  # noqa: E501
                toc_tokens.append({
                    'level': int(el.tag[-1]),
                    'id': el.attrib["id"],
                    'name': unescape(stashedHTML2text(
                        code_escape(el.attrib.get('data-toc-label', text)),
                        self.md, strip_entities=False
                    ))
                })
            # Remove the data-toc-label attribute as it is no longer needed
            if 'data-toc-label' in el.attrib:
                del el.attrib['data-toc-label']
            if self.use_anchors:
                self.add_anchor(el, el.attrib["id"])
            if self.use_permalinks not in [False, None]:
                self.add_permalink(el, el.attrib["id"])
    toc_tokens = nest_toc_tokens(toc_tokens)
    div = self.build_toc_div(toc_tokens)
    div.attrib["c2c:role"] = "toc"
    del div.attrib["class"]
    if self.marker:
        self.replace_marker(doc, div)
    # serialize and attach to markdown instance.
    toc = self.md.serializer(div)
    for pp in self.md.postprocessors:
        toc = pp.METHOD_NAME(toc)
    self.md.toc_tokens = toc_tokens
    self.md.toc = toc