def _order_cluster_tree(Z):
    q = deque()
    tree = to_tree(Z)
    q.append(tree)
    nodes = []

    while q:
        node = q.popleft()
        if not node.is_leaf():
            bisect.insort_left(nodes, node)
            q.append(node.get_right())
            q.append(node.get_left())
    return nodes
Returns clustering nodes in bottom-up order by distance.
dataset/ETHPy150Open scipy/scipy/scipy/cluster/hierarchy.py/_order_cluster_tree