code: def toc(self, depth=6, lowest_level=6):
          
          depth = min(max(depth, 0), 6)
          depth = 6 if depth == 0 else depth
          lowest_level = min(max(lowest_level, 1), 6)
          toc = self._root.to_dict()['children']
  
          def traverse(curr_toc, dep, lowest_lvl, curr_depth=1):
              if curr_depth > dep:
                  # clear all items of this depth and exit the recursion
                  curr_toc.clear()
                  return
  
              items_to_remove = []
              for item in curr_toc:
                  if item['level'] > lowest_lvl:
                      # record item with low header level, for removing it later
                      items_to_remove.append(item)
                  else:
                      traverse(item['children'], dep, lowest_lvl, curr_depth + 1)
              [curr_toc.remove(item) for item in items_to_remove]
  
          traverse(toc, depth, lowest_level)
          return toc
docs: Get table of content of currently fed HTML string.
  
          :param depth: the depth of TOC
          :param lowest_level: the allowed lowest level of header tag
          :return: a list representing the TOC