adding "returning entire subtree" optimization