title: Create nested object from multiple string paths
body: <p>I'm looking for the best way to convert multiple string paths to a nested object with javascript. I'm using lodash if that could help in any way.</p>
  
  <p>I got the following paths:</p>
  
  <pre><code>/root/library/Folder 1
  /root/library/Folder 2
  /root/library/Folder 1/Document.docx
  /root/library/Folder 1/Document 2.docx
  /root/library/Folder 2/Document 3.docx
  /root/library/Document 4.docx
  </code></pre>
  
  <p>and I would like to create the following array of object:</p>
  
  <pre><code>  var objectArray =
      [
        {
          "name": "root", "children": [
            {
              "name": "library", "children": [
                {
                  "name": "Folder 1", "children": [
                    { "name": "Document.docx", "children": [] },
                    { "name": "Document 2.docx", "children": [] }
                  ]
                },
                {
                  "name": "Folder 2", "children": [
                    { "name": "Document 3.docx", "children": [] }
                  ]
                },
                {
                  "name": "Document 4.docx", "children": []
                }
              ]
            }
          ]
        }
      ];
  </code></pre>