changed implementation to an immutable AVL+ tree.