binary search tree in javascript using a rec method