def _yield_branch_objects(branch, node):
    """Yield each subbranch for each given branch.

    A subbranch is represented by a dict with the 'leaf'
    key containing the leaf node and the 'stem' key
    containing a list of all nodes leading to the leaf.

    Parameters
    ==========
    branch (list)
        node objects leading to the leaf.
    node (dict)
        a node containing more nodes and/or leaves.
    """
    ### iterate over all items in the given node

    for key, value in node.items():

        ## if the value is a mapping, then we look deeper
        ## into the branch

        if isinstance(value, Mapping):

            yield from _yield_branch_objects(branch[:] + [key], value)

        ## otherwise the value is a leaf; we can finally
        ## yield it along with its stem, both inside a
        ## dict representing the branch

        else:
            yield {
                "stem": branch[:] + [key],
                "leaf": value,
            }
Yield each subbranch for each given branch.

    A subbranch is represented by a dict with the 'leaf'
    key containing the leaf node and the 'stem' key
    containing a list of all nodes leading to the leaf.

    Parameters
    ==========
    branch (list)
        node objects leading to the leaf.
    node (dict)
        a node containing more nodes and/or leaves.
    
nodezator/ourstdlibs/treeutils.py