Automatically order tree nodes