Bugfix: Reuse distance counting.

This patch fixes an issue with the reuse distance counting, whereby the
distance is calculated as the number of tree nodes that were added after a
specific node was added to the tree. This patch does not completely solve the
problem, though -- as the underlying AVL tree code does not support node
deletion. Including this support should reduce the number of passes that need
to be made over nodes that represent references.

Further reduction in the passes should be possible from recording the number of
nodes in any given subtree. At the moment, the code walks over subtrees to
count nodes. In combination with the previous optimizations, the true benefit
of using AVL trees for counting reuse distances should be possible.