Made tree-traversal significantly faster, to the point of being usable.

Adjusted how the colours are sorted to make a colour-greedy assignment
prettier.