I am sorting a nested tree with this function (found here and here):
sortTree(tree) { const sorted_tree = tree.sort