Creating a binary tree in javascript