JavaScript implementation of BST