Added method to compute the depth of the tree