Create Tree From Array Javascript Function Syntax