Tree Data Structure In Javascript