binary search tree implemented in purely functional fashion (scala)