Implementation of bst.h