Binary Tree implementation in JavaScript