Implementing binary tree js