Refine the code of BinarySearchTree and related class.