title: Print complete key path for all the values of a python nested dictionary
body: <p>If below is my nested dictionary I want to parse through recursively and print all the values along with the complete path of the nested key.</p>
  
  <pre><code>my_dict = {'attr':{'types':{'tag':{'name':'Tom', 'gender':'male'},'category':'employee'}}}
  </code></pre>
  
  <p><strong>Expected output:</strong></p>
  
  <pre><code>Key structure : my_dict["attr"]["types"]["tag"]["name"]&lt;br&gt;
  value : "Tom"&lt;br&gt;
  Key structure : my_dict["attr"]["types"]["tag"]["gender"]&lt;br&gt;
  value : "male"&lt;br&gt;
  Key structure : my_dict["attr"]["types"]["category"]&lt;br&gt;
  value : "employee"&lt;br&gt;
  </code></pre>
  
  <p>I wrote a recursive function, but running to this:<br></p>
  
  <pre><code>my_dict = {'attr':{'types':{'tag':{'name':'Tom','gender':'male'},'category':'employee'}}}
  
  def dict_path(path,my_dict):
      for k,v in my_dict.iteritems():
          if isinstance(v,dict):
              path=path+"_"+k
              dict_path(path,v)
          else:
              path=path+"_"+k
              print path,"=&gt;",v
  
      return
  dict_path("",my_dict)
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <p>_attr_types_category => employee<br>
  _attr_types_category_tag_gender => male<br>
  _attr_types_category_tag_gender_name => Tom<br></p>
  
  <p>In the above : For male, the key struct shouldnt contain "category"
  How to retain the correct key structure?</p>