Create Tree Data Structure Javascript Array Functions