def _find_toc_by_id(self, toc, id_: str | None) -> AnchorLink | None:
        """
        Given a table of contents and HTML ID, iterate through
        and return the matched item in the TOC.
        """
        for toc_item in toc:
            if toc_item.id == id_:
                return toc_item
            toc_item_r = self._find_toc_by_id(toc_item.children, id_)
            if toc_item_r is not None:
                return toc_item_r
        return None

        Given a table of contents and HTML ID, iterate through
        and return the matched item in the TOC.
        
mkdocs/contrib/search/search_index.py