Added caching support for tree.