Shuffles the leaf labels, but doesn't alter the tree structure

def randomise_labels(
            self,
            inplace=False,
    ):
        """ Shuffles the leaf labels, but doesn't alter the tree structure """

        if not inplace:
            t = self.copy()
        else:
            t = self

        names = list(t.labels)
        random.shuffle(names)
        for l in t._tree.leaf_node_iter():
            l.taxon._label = names.pop()
        t._dirty = True
        return t