function cleanup(roots) {
let root_array = new Array(roots.length);
roots.forEach((t) => {
let x = t;
while (root_array[x.degree] !== undefined) {
let u = root_array[x.degree];
root_array[x.degree] = undefined;
let x = merge(x, u);
root_array[x.degree] = x;
}
});
return root_array.reverse().filter((t) => t !== undefined);
};