Create Tree From Array Javascript Methods