title: How could I convert an array of paths into nested array or hash dependant upon length
body: <p>I need to convert an array of string paths into an array of symbols, hashes and arrays dependant upon the length of the string path</p>
  
  <p>Given the following array:</p>
  
  <pre class="lang-rb prettyprint-override"><code>array = ["info", "services", "about/company", "about/history/part1", "about/history/part2"]
  
  </code></pre>
  
  <p>I would like to produce the following output, grouping the different levels, using a mixture of symbols and objects depending on the structure at the level.</p>
  
  <p>Produce the following output:</p>
  
  <pre class="lang-rb prettyprint-override"><code>[
    :info,
    :services,
    about: [
      :company,
      history: [
        :part1,
        :part2
      ]
    ]
  ]
  
  # alt syntax
  [
    :info,
    :services,
    {
      :about =&gt; [
        :company,
        {
          :history =&gt; [
            :part1,
            :part2
          ]
        }
      ]
    }
  ]
  </code></pre>
  
  <p>If a path has sub paths, it would become an object
  If there is no sub paths, the path is converted to a symbol.</p>
  
  <p>I am struggling with supporting infinite recursion deciding when and how to make the object.</p>