Javascript implementation of binary search trees