code: def _find_toc_node(toc, ref_id, objtype):
      
      for check_node in toc.traverse(nodes.reference):
          if objtype == nodes.section and (
              check_node.attributes["refuri"] == ref_id
              or check_node.attributes["anchorname"] == "#" + ref_id
          ):
              return check_node
          if (
              objtype == addnodes.desc
              and check_node.attributes["anchorname"] == "#" + ref_id
          ):
              return check_node
      return None
docs: Find the actual TOC node for a ref_id.
  
      Depends on the object type:
      * Section - First section (refuri) or 2nd+ level section (anchorname)
      * Desc - Just use the anchor name