Binary search tree in JavaScript