Move tree related implementation to separate pacakge.

Because it's logical independent