title: Need to create a Python Level structure of dictionaries using key value pair
body: <p>I'll try my best to explain my problem. Currently I have a dictionary (named level_map) which contains keys and values (the values are the level in which the key should be stored)</p>
  
  <p>Ex:</p>
  
  <p>name: Test
  value: 1</p>
  
  <p>name: Test2
  value: 2</p>
  
  <p>name: Test3
  value: 3</p>
  
  <p>name: Test4
  value: 3</p>
  
  <p>should look like this</p>
  
  <pre><code>Test
  |
  |---Test2
        |
        |---Test3
              |
              |---Test4
              |---Test5
  </code></pre>
  
  <p>What my question is, how do I take level_map (my dict obj) and convert it so that it is a dict within a dict for all the different levels because ultimately, I'll be creating a table view on a webpage. I've tried to wrap my head around this and I'm just stuck on where to start. Any starting pointers would be great. Thanks guys.</p>
  
  <p><strong>EDIT</strong>
  Here is how my level_map (dict obj) is structured:</p>
  
  <pre><code>level_map = {
    "Test": 1,
    "Test2": 2,
    "Test3": 3,
    "Test4": 4,
    "Test5": 4
  }
  </code></pre>
  
  <p>What I want the new dict obj to be is this:</p>
  
  <pre><code>new_level_map = {
  "Test":{
    "Test2":{
      "Test3": {
          "Test4",
          "Test5"
         }
       }
     }
  }
  </code></pre>