class_docstr: Tree node data structure
  
  Nodes have an attribute item to carry arbitrary information. A node may only have one parent
  and can have as many children as desired.
  
  Parents can be set at initialization or via `node.set_parent`. Setting a parent automatically
  set the current node as the child of the parent.
  
  Children can be set at initialization or via `node.add_children`. Setting children
  automatically set their parent as the current node.
  
  Tree of nodes are iterable, by default with preorder traversal.
  
  .. seealso::
      `orion.core.utils.tree.PreOrderTraversal`
      `orion.core.utils.tree.DepthFirstTraversal`
  
  Attributes
  ----------
  item: T
      Can be anything
  parent: None or instance of `orion.core.utils.tree.TreeNode`
      The parent of the current node, None if the current node is the root.
  children: None or list of instances of `orion.core.utils.tree.TreeNode`
      The children of the current node.
  root: instance of `orion.core.utils.tree.TreeNode`
      The top node of the current tree. The root node returns itself.
  
  Examples
  --------
  .. code-block:: python
      :linenos:
  
      a = TreeNode("a")
      b = TreeNode("b", a)
      c = TreeNode("c", a)
      d = TreeNode("d", a)
      e = TreeNode("e", a)
  
      f = TreeNode("f", b)
      g = TreeNode("g", b)
  
      h = TreeNode("h", e)
  
      # Gives this tree
      # a
      # |   \  \   \
      # b    c  d   e
      # | \         |
      # f  g        h
  
      g.set_parent(e)
  
      # Gives this tree
      # a
      # |  \  \   \
      # b   c  d   e
      # |          | \
      # f          h g
  
      c.add_children(h, g)
  
      # Gives this tree
      # a
      # |  \    \   \
      # b   c    d   e
      # |   | \
      # f   h  g
  
      a.drop_children(c)
  
      # Gives this tree
      # a
      # |  \   \
      # b   d   e
      # |
      # f
class_docstr_tok: ["Tree","node","data","structure","Nodes","have","an","attribute","item","to","carry","arbitrary","information",".","A","node","may","only","have","one","parent","and","can","have","as","many","children","as","desired",".","Parents","can","be","set","at","initialization","or","via","`","node.set_parent","`",".","Setting","a","parent","automatically","set","the","current","node","as","the","child","of","the","parent",".","Children","can","be","set","at","initialization","or","via","`","node.add_children","`",".","Setting","children","automatically","set","their","parent","as","the","current","node",".","Tree","of","nodes","are","iterable",",","by","default","with","preorder","traversal",".","..","seealso",":",":","`","orion.core.utils.tree.PreOrderTraversal","`","`","orion.core.utils.tree.DepthFirstTraversal","`","Attributes","--","--","--","--","--","item",":","T","Can","be","anything","parent",":","None","or","instance","of","`","orion.core.utils.tree.TreeNode","`","The","parent","of","the","current","node",",","None","if","the","current","node","is","the","root",".","children",":","None","or","list","of","instances","of","`","orion.core.utils.tree.TreeNode","`","The","children","of","the","current","node",".","root",":","instance","of","`","orion.core.utils.tree.TreeNode","`","The","top","node","of","the","current","tree",".","The","root","node","returns","itself",".","Examples","--","--","--","--","..","code-block",":",":","python",":","linenos",":","a","=","TreeNode","(","``","a","''",")","b","=","TreeNode","(","``","b","''",",","a",")","c","=","TreeNode","(","``","c","''",",","a",")","d","=","TreeNode","(","``","d","''",",","a",")","e","=","TreeNode","(","``","e","''",",","a",")","f","=","TreeNode","(","``","f","''",",","b",")","g","=","TreeNode","(","``","g","''",",","b",")","h","=","TreeNode","(","``","h","''",",","e",")","#","Gives","this","tree","#","a","#","|","\\","\\","\\","#","b","c","d","e","#","|","\\","|","#","f","g","h","g.set_parent","(","e",")","#","Gives","this","tree","#","a","#","|","\\","\\","\\","#","b","c","d","e","#","|","|","\\","#","f","h","g","c.add_children","(","h",",","g",")","#","Gives","this","tree","#","a","#","|","\\","\\","\\","#","b","c","d","e","#","|","|","\\","#","f","h","g","a.drop_children","(","c",")","#","Gives","this","tree","#","a","#","|","\\","\\","#","b","d","e","#","|","#","f"]
docstr: Drop the parent of the node, do nothing if no parent
  
  Note that the node will be removed from the children of the parent as well
docstr_tok: ["Drop","the","parent","of","the","node",",","do","nothing","if","no","parent","Note","that","the","node","will","be","removed","from","the","children","of","the","parent","as","well"]
code: def drop_parent(self) -> None:
      """Drop the parent of the node, do nothing if no parent
  
      Note that the node will be removed from the children of the parent as well
      """
      if self.parent is not None:
          assert self._parent is not None
          self._parent.drop_children(self)
  
imports: from __future__ import annotations
  from typing import Callable, Generic, Iterable, Iterator, Sequence, TypeVar
label_desc: Use image node_id 5 for calling the TreeNode obj's underlying member method code with example usage: obj.drop_parent() without return types