title: Construct a tree from list os file paths (Python) - Performance dependent
body: <p>Hey I am working on a very high performance file-managing/analyzing toolkit written in python.
  I want to create a function that gives me a list or something like that in a  tree format.
  Something like in this <a href="https://stackoverflow.com/questions/1005551/construct-a-tree-structure-from-list-of-string-paths">question (java-related)</a></p>
  
  <p>From:</p>
  
  <pre><code>dir/file
  dir/dir2/file2
  dir/file3
  dir3/file4
  dir3/file5
  </code></pre>
  
  <p>Note: the list of paths is unsorted</p>
  
  <p>To:</p>
  
  <pre><code>dir/
      file
      dir2/
          file2
      file3
  dir3/
      file4
      file5
  
  [[dir, [file, [dir2, [file2]], file3]], [dir3, [file4, file5]]]
  </code></pre>
  
  <p>something along those lines. I've been playing around with some ideas but none of them provided the speed that I would like to have.</p>
  
  <p>Note: I do already have the list of paths, so no worrying about that. The function takes paths list and gives tree list.</p>
  
  <p>Thanks in Advance</p>