title: dict of dicts python
body: <p>I have a python dictionary consisting of other dictionaries like so (example):</p>
  
  <pre><code>{2: {4: {5: {6: {7: None}}}, 7: None}, 7: None}
  </code></pre>
  
  <p>I would like to extract the keys so that I end up with:</p>
  
  <pre><code>[2,4,5,6,7,None]
  [2,7,None]
  [7,None]
  </code></pre>
  
  <p>I have tried to solve this problem with a recursive function, however with no luck...</p>
  
  <pre><code>def f(d):
      paths = []
      try:
          for key in f.keys():
              path.append(f(d[key]))
      pass:
          pass
  </code></pre>
  
  <p>Is there a way to do this and how?</p>