Fixed bug in calculation of leftOnTree and rightOnTree.