title: Convert nested array of objects into nested property template object
body: <p>I have an array of objects created that I would like to convert into a nested property template object. The nested object will be created based on items that are checked. </p>
  
  <p>The first level of objects have their 'checked' key set to null as they will always be added as the beginning of the property template object. </p>
  
  <p>If the first level objects have no properties, or the none of the properties are checked, then it should look like this: </p>
  
  <pre><code>{staff: true}
  </code></pre>
  
  <p>However, if the objects have properties and some of the properties are checked, it will look like this: </p>
  
  <pre><code>{staffedLocation: ['schedulingGroup',
                     {property: 'staff', subProperties: ['description']}
                    ]
  }
  </code></pre>
  
  <p>This is a very simple example and in some cases the array of nested objects can go further down, so I know I need to create a recursive function. However, I'm getting tripped up as to how I can go about creating it recursively when the first level of the object is entirely different from the rest of it. </p>
  
  <p>An example of the array of objects on hand looks like this:</p>
  
  <pre><code>[
      {checked: null, name: "staffedLocation", properties: [
          {checked: null, name: "oid", properties: null, toggle: null, type: "integer"},
          {checked: null, name: "_class", properties: null, toggle: null, type: "string"},
          {checked: true, name: "schedulingGroups", properties: null, toggle: null, type: "list"},
          {checked: null, name: "staff", properties: [
              {checked: null, name: "oid", properties: null, toggle: null, type: "integer"},
              {checked: null, name: "_class", properties: null, toggle: null, type: "string"},
              {checked: true, name: "description", properties: null, toggle: null, type: "string"},
              {checked: null, name: "limits", properties: null, toggle: null, type: "list"},
              {checked: null, name: "weeklyMaxHours", properties: null, toggle: null, type: "integer"}
  
          ], toggle: true, type: "list"},
      ], toggle: true, type: "staffedLocation"},
      {checked: null, 
      name: "staff", properties: [
          {checked: null, name: "oid", properties: null, toggle: null, type: "integer"},
          {checked: null, name: "_class", properties: null, toggle: null, type: "string"},
          {checked: null, name: "description", properties: null, toggle: null, type: "string"},
          {checked: null, name: "limits", properties: null, toggle: null, type: "list"},
          {checked: null, name: "weeklyMaxHours", properties: null, toggle: null, type: "integer"}
      ], toggle: true, type: "staff"},
      {checked: null, name: "assignedShifts", properties: null, toggle: null, type: "shiftForEmail"},
      {checked: null, name: "editedShifts", properties: null, toggle: null, type: "shiftForEmail"},
      {checked: null, name: "deletedShifts", properties: null, toggle: null, type: "shiftForEmail"},
      {checked: null, name: "unassignedShifts", properties: null, toggle: null, type: "shiftForEmail"},
      {checked: null, name: "rangeStart", properties: null, toggle: null, type: "timestamp"},
      {checked: null, name: "rangeEnd", properties: null, toggle: null, type: "timestamp"}
  ]
  </code></pre>
  
  <p>And I would like it to then be converted into a nested object like so:</p>
  
  <pre><code>{   
      staffedLocation: ['schedulingGroup',{property: 'staff',subProperties: ['description']}],
      staff: true,
      assignedShifts: true,
      editedShifts: true,
      deletedShifts: true,
      unassignedShifts: true,
      rangeStart: true,
      rangeEnd: true
  }
  </code></pre>