Tree building: eliminate needless copying.

This is achieved by switching of temporary storage container on every level of depth.
Merge pull request #28 from stanislaw/faster_tree_build

Tree building: eliminate needless memory copying.