Add first stab at rotate-to-root tree.

Crappier splay tree. The operations are implemented in a
single-traversal top-down fashion.

Move some functions shared with the search tree implementation to
tree.c.