# pydicom.fileset.RecordNode

class pydicom.fileset.RecordNode(record: Optional[pydicom.dataset.Dataset] = None)

  Representation of a DICOMDIR’s directory record.

  children

    The current node’s child nodes (if any)

    Type

      list of RecordNode

  instance

    If the current node is a leaf node, a `FileInstance` for the corresponding SOP Instance.

    Type

      FileInstance or None

  __init__(record: Optional[pydicom.dataset.Dataset] = None) → None

    Create a new `RecordNode`.

    Parameters

      record (pydicom.dataset.Dataset, optional) – A Directory Record Sequence’s directory record.

  Methods

  `__init__`([record]) | Create a new `RecordNode`.
  `add`(leaf) | Add a leaf to the tree.
  `prettify`([indent_char]) | Return the tree structure as a list of pretty strings, starting at the current node (unless the current node is the root node).
  `remove`(node) | Remove a leaf from the tree
  `reverse`() | Yield nodes up to the level below the tree's root node.

  Attributes

  `ancestors` | Return a list of the current node's ancestors, ordered from nearest to furthest.
  `component` | Return a File ID component as `str` for the current node.
  `depth` | Return the number of nodes to the level below the tree root
  `file_set` | Return the tree's `FileSet`.
  `has_instance` | Return `True` if the current node corresponds to an instance.
  `index` | Return the index of the current node amongst its siblings.
  `is_root` | Return `True` if the current node is the tree's root node.
  `key` | Return a unique key for the node's record as `str`.
  `next` | Return the node after the current one (if any), or `None`.
  `parent` | Return the current node's parent (if it has one).
  `previous` | Return the node before the current one (if any), or `None`.
  `record_type` | Return the record's Directory Record Type as `str`.
  `root` | Return the tree's root node.

  add(leaf: pydicom.fileset.RecordNode) → None

    Add a leaf to the tree.

    Parameters

      leaf (pydicom.fileset.RecordNode) – A leaf node (i.e. one with a `FileInstance`) to be added to the tree (if not already present).

  property ancestors: List[pydicom.fileset.RecordNode]

    Return a list of the current node’s ancestors, ordered from nearest to furthest.

  property component: str

    Return a File ID component as `str` for the current node.

  property depth: int

    Return the number of nodes to the level below the tree root

  property file_set: pydicom.fileset.FileSet

    Return the tree’s `FileSet`.

  property has_instance: bool

    Return `True` if the current node corresponds to an instance.

  property index: int

    Return the index of the current node amongst its siblings.

  property is_root: bool

    Return `True` if the current node is the tree’s root node.

  property key: str

    Return a unique key for the node’s record as `str`.

  property next: Optional[pydicom.fileset.RecordNode]

    Return the node after the current one (if any), or `None`.

  property parent: pydicom.fileset.RecordNode

    Return the current node’s parent (if it has one).

  prettify(indent_char: str = ' ') → List[str]

    Return the tree structure as a list of pretty strings, starting at the current node (unless the current node is the root node).

    Parameters

      indent_char (str, optional) – The characters to use to indent each level of the tree.

  property previous: Optional[pydicom.fileset.RecordNode]

    Return the node before the current one (if any), or `None`.

  property record_type: str

    Return the record’s Directory Record Type as `str`.

  remove(node: pydicom.fileset.RecordNode) → None

    Remove a leaf from the tree

    Parameters

      node (pydicom.fileset.RecordNode) – The leaf node (i.e. one with a `FileInstance`) to remove.

  reverse() → Iterable[pydicom.fileset.RecordNode]

    Yield nodes up to the level below the tree’s root node.

  property root: pydicom.fileset.RecordNode

    Return the tree’s root node.