class_docstr: A generic tree branch.
  
  Parameters
  ----------
  children
      Child branches and/or leaves.
class_docstr_tok: ["A","generic","tree","branch",".","Parameters","--","--","--","--","--","children","Child","branches","and\/or","leaves","."]
docstr: Build a DataFrame containing one record for each node.
docstr_tok: ["Build","a","DataFrame","containing","one","record","for","each","node","."]
code: def to_dataframe(self) -> pd.DataFrame:
      """Build a DataFrame containing one record for each node."""
      node_ids: defaultdict[typing.Hashable, int] = defaultdict(lambda: len(node_ids))  # type: ignore
      nodes = []
  
      queue: Queue = Queue()
      queue.put((self, None, 0))
  
      while not queue.empty():
          node, parent, depth = queue.get()
          nodes.append(
              {
                  "node": node_ids[id(node)],
                  "parent": node_ids[id(parent)] if parent else pd.NA,
                  "is_leaf": isinstance(node, Leaf),
                  "depth": depth,
                  **{
                      k: v
                      for k, v in node.__dict__.items()
                      if k != "children"
                  },
              }
          )
          try:
              for child in node.children:
                  queue.put((child, node, depth + 1))
          except AttributeError:
              pass
  
      return pd.DataFrame.from_records(nodes).set_index("node")
  
imports: from __future__ import annotations
  import abc
  import typing
  from collections import defaultdict
  from queue import Queue
  from xml.etree import ElementTree
  import pandas
  from river import base
label_desc: Use image node_id 16 for calling the Branch obj's underlying member method code with example usage: obj.to_dataframe() and returns: pd