def subtree(self: Tree) -> Iterator[Tree]:
        """
        Iterate over all nodes in this tree, including both self and all descendants.

        Iterates breadth-first.

        See Also
        --------
        DataTree.subtree_with_keys
        DataTree.descendants
        group_subtrees
        """
        # https://en.wikipedia.org/wiki/Breadth-first_search#Pseudocode
        queue = collections.deque([self])
        while queue:
            node = queue.popleft()
            yield node
            queue.extend(node.children.values())

        Iterate over all nodes in this tree, including both self and all descendants.

        Iterates breadth-first.

        See Also
        --------
        DataTree.subtree_with_keys
        DataTree.descendants
        group_subtrees
        
xarray/core/treenode.py