@staticmethod
    def sort(cases):
        # Handles cases from tests, but not proven to handle an arbitrary
        # collection of cases.
        uuids = set()
        roots = []
        for case in cases:
            if case.uuid in uuids:
                raise RuntimeError('Duplicate uuid! %s' % case.uuid)
            uuids.add(case.uuid)

            node = CaseTreeNode(case, None)
            for root in list(roots):
                if case.uuid == root.case.parent_uuid:
                    root.parent = node
                    node.children.append(root)
                    roots.remove(root)
                else:
                    if root._insert(node):
                        break
            else:
                roots.append(node)

        # Rescan roots trying to consolidate the forest.
        old_len = len(roots)
        new_len = 0
        while new_len < old_len:
            old_len = len(roots)
            for node in list(roots):
                for root in list(roots):
                    if node is root:
                        continue
                    elif node.case.uuid == root.case.parent_uuid:
                        root.parent = node
                        node.children.append(root)
                        roots.remove(root)
                    elif root._insert(node):
                        roots.remove(node)
            new_len = len(roots)

        return roots
Return forest populated from `cases`.
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/case.py/CaseTreeNode.sort