title: Single dictionary of fewer keys from a multi level dictionary
body: <p>I am looking for a way to get values from variable depth in a multi level dictionary. I have a list of keys that are to be looked upon in the multi level dictionary. This key and value is to be put into a new dictionary.</p>
  
  <pre><code>needed_keys = ["a1", "b1", "c1", "d1", "e1"]
  original_dict = {"x" : {"xa1" : 5, "xaa" : True, "xaaa" : {"xaaab1" : True, "xaaabb" : False}}, "y" : {"yz" : 6.0, "yc1" : 7.0, "yf" : {"yfd1" : "a string"}}}
  
  final_result = {"a1" : 5, "b1" :True, "c1" : 7.0, "d1" : "a string", "e1" : None}
  </code></pre>
  
  <p>So basically this:</p>
  
  <ol>
  <li>Get a key name to be looked upon</li>
  <li>Traverse the dictionary and check whether <code>dict_key.endswith(key_name)</code></li>
  <li>Assign the value from the <code>original_dict</code>, if found; set to <code>None</code> otherwise</li>
  <li>Repeat from 1 until the end of the list</li>
  </ol>
  
  <p>Is this possible with less traversing through the <code>original_dict</code>? This is optional as speed is not an issue here. I am totally lost in here with less messy code.</p>