def _collapse_leaves(self, active_nodes):

        for ix in active_nodes:
            subtree = self._make_subtree(ix)

            max_end_level = max([v.end_level for v in subtree.nodes.values()])
            max_end_mass = max([v.end_mass for v in subtree.nodes.values()])

            self.nodes[ix].end_level = max_end_level
            self.nodes[ix].end_mass = max_end_mass
            self.nodes[ix].children = []

            for u in subtree.nodes.keys():
                if u != ix:
                    del self.nodes[u]
Removes descendant nodes for the branches in 'active_nodes'.
dataset/ETHPy150Open CoAxLab/DeBaCl/debacl/level_set_tree.py/LevelSetTree._collapse_leaves