code: def filter_doctree_for_slides(doctree):
      
  
      current = 0
      num_children = len(doctree.children)
      while current < num_children:
  
          child = doctree.children[current]
          child.replace_self(
              child.traverse(no_autoslides_filter)
          )
  
          if len(doctree.children) == num_children:
              # nothing removed, increment current
              current += 1
          else:
              # a node was removed; retain current and update length
              num_children = len(doctree.children)
docs: Given a doctree, remove all non-slide related elements from it.