replace SortedHash with an BinaryTree