imas.util.tree_iter¶
-
imas.util.tree_iter(node: IDSBase, *, leaf_only: bool =
True, visit_empty: bool =False, accept_lazy: bool =False, include_node: bool =False) Iterator[IDSBase]¶ Tree iterator for IMAS-Python structures.
Iterate (depth-first) through the whole subtree of an IMAS-Python structure.
- Parameters:
- Keyword Arguments:
- leaf_only: bool =
True¶ Iterate over:
True: Only leaf nodes, not internal nodesFalse: All nodes, including internal nodes
- visit_empty: bool =
False¶ When set to True, iterate over empty nodes.
- accept_lazy: bool =
False¶ See documentation of
iter_nonempty_(). Only relevant whenvisit_emptyis False.- include_node: bool =
False¶ When set to True the iterator will include the provided node (if the node is not a leaf node, it is included only when
leaf_onlyis False).
- leaf_only: bool =
Example
# Iterate over all filled leaf nodes in a given IMAS-Python IDSToplevel for node in tree_iter(toplevel): print(node)See also
visit_children()for the functional variant of this method.
Last update:
2026-01-28