fix add function; semantic for recursion: find the maximal reachable node from the position p + 1. If this node is not a leaf, traverse recursively to the most right(= smallest) child  and then update the node count of the reached depth respectively.