imas.util.visit_children

imas.util.visit_children(func: Callable, node: IDSBase, *, leaf_only: bool = True, visit_empty: bool = False, accept_lazy: bool = False) None

Apply a function to node and its children

IMAS-Python objects generally live in a tree structure. Similar to Pythons map(), this method can be used to apply a function to objects within this tree structure.

Parameters:
func: Callable

Function to apply to each selected node.

node: IDSBase

Node that function func will be applied to. The function will be applied to the node itself and all its descendants, depending on leaf_only.

Keyword Arguments:
leaf_only: bool = True

Apply function to:

  • True: Only leaf nodes, not internal nodes

  • False: All nodes, including internal nodes

visit_empty: bool = False

When set to True, also apply the function to empty nodes.

accept_lazy: bool = False

See documentation of iter_nonempty_(). Only relevant when visit_empty is False.

Example

# Print all filled leaf nodes in a given IMAS-Python IDSToplevel
visit_children(print, toplevel)

See also

tree_iter() for the iterator variant of this method.


Last update: 2026-01-28