# Path: uqbar/iterables.py
# def nwise(iterable, n=2):
#     iterables = itertools.tee(iterable, n)
#     temp = []
#     for idx, it in enumerate(iterables):
#         it = itertools.islice(it, idx, None)
#         temp.append(it)
#     return zip(*temp)


import copy
import typing
from uqbar.iterables import nwise
        Get graph-order tuple for node.

        ::

            >>> from uqbar.containers import UniqueTreeList, UniqueTreeNode
            >>> root_container = UniqueTreeList(name="root")
            >>> outer_container = UniqueTreeList(name="outer")
            >>> inner_container = UniqueTreeList(name="inner")
            >>> node_a = UniqueTreeNode(name="a")
            >>> node_b = UniqueTreeNode(name="b")
            >>> node_c = UniqueTreeNode(name="c")
            >>> node_d = UniqueTreeNode(name="d")
            >>> root_container.extend([node_a, outer_container])
            >>> outer_container.extend([inner_container, node_d])
            >>> inner_container.extend([node_b, node_c])

        ::

            >>> for node in root_container.depth_first():
            ...     print(node.name, node.graph_order)
            ...
            a (0,)
            outer (1,)
            inner (1, 0)
            b (1, 0, 0)
            c (1, 0, 1)
            d (1, 1)

        """
        graph_order = []

# Path: uqbar/iterables.py
# def nwise(iterable, n=2):
#     iterables = itertools.tee(iterable, n)
#     temp = []
#     for idx, it in enumerate(iterables):
#         it = itertools.islice(it, idx, None)
#         temp.append(it)
#     return zip(*temp)


# Path: uqbar/containers/UniqueTreeNode.py
import copy
import typing
from uqbar.iterables import nwise

        Get graph-order tuple for node.

        ::

            >>> from uqbar.containers import UniqueTreeList, UniqueTreeNode
            >>> root_container = UniqueTreeList(name="root")
            >>> outer_container = UniqueTreeList(name="outer")
            >>> inner_container = UniqueTreeList(name="inner")
            >>> node_a = UniqueTreeNode(name="a")
            >>> node_b = UniqueTreeNode(name="b")
            >>> node_c = UniqueTreeNode(name="c")
            >>> node_d = UniqueTreeNode(name="d")
            >>> root_container.extend([node_a, outer_container])
            >>> outer_container.extend([inner_container, node_d])
            >>> inner_container.extend([node_b, node_c])

        ::

            >>> for node in root_container.depth_first():
            ...     print(node.name, node.graph_order)
            ...
            a (0,)
            outer (1,)
            inner (1, 0)
            b (1, 0, 0)
            c (1, 0, 1)
            d (1, 1)

        """
        graph_order = []

        for parent, child in nwise(reversed(self.parentage)):