Fix storage order of tree nodes when trees are split.

Fixes #551