Reversing Binary Tree with JavaScript