JS - Tree implementation