#84 Convert tail recursion into iteration in TreeNode.updateStats