title: Iterate through items of an arbitrary layered dictionary in Python
body: <p>I have a dictionary in Python with an <strong>increasing number of layers</strong> in iterations.</p>
  
  <p>I want to iterate through the values that exist in the last layer.</p>
  
  <p>Suppose this dict:</p>
  
  <pre><code>d = {'a':{'a':2},'b':{'c':2},'x':{'a':2}}
  #the intuitive solution is
  for key1,val in d.items():
      for key2,val2 in val.items():
          #integer value in val2, HOORAY
  </code></pre>
  
  <p>Now if we add an layer the loop goes:</p>
  
  <pre><code>d = {'a':{'a':{'y':2}},'b':{'c':{'a':5}},'x':{'a':{'m':6}}}
  #the intuitive solution is
  for key1,val in d.items():
      for key2,val2 in val.items():
          for key3,val3 in val2.items():
               #integer value in val3
  </code></pre>
  
  <p>I look for a dynamic solution of arbitrary dimensions iteration</p>
  
  <p>Consider the number of layers known and fixed for all elements in an iteration if that helps.</p>
  
  <p>Additionally I like to know how an integer is mapped in the dict.</p>