JS Binary Tree implementation for CD