convert the array to an object tree