Binary Search Tree - algo in JavaScript