Accepted :-)
pre-compute the tree heights