Created functional BST implementation