Added counting methods in tree.