title: Python: iterate over a nested dictionary
body: <p>given the following <code>dictionary</code>:</p>
  
  <pre><code>playlists={'user':[
                 {'playlist1':{
                      'tracks': [        
                      {'name': 'Karma Police','artist': 'Radiohead', 'count': "1.0"},
                      {'name': 'Bitter Sweet Symphony','artist': 'The Verve','count': "2.0"}                    
                       ]
                      }
                 },
                 {'playlist2':{
                      'tracks': [        
                      {'name': 'We Will Rock You','artist': 'Queen', 'count': "3.0"},
                      {'name': 'Roxanne','artist': 'Police','count': "5.0"}                    
                       ]
                    }
                  },
                ]
              }
  </code></pre>
  
  <p>though not very elegantly, I can fetch keys and values in such a structure:</p>
  
  <p><code>keys</code>:</p>
  
  <pre><code>userX = [user[0] for user in playlists.iteritems()][0] //userX
  playlist1 = list(playlists['userX'][0].keys())[0] //playlist1
  </code></pre>
  
  <p>and nested <code>values</code>:</p>
  
  <pre><code>artist = playlists['user'][0]["playlist1"]['tracks'][0]['artist'] //Radiohead
  count = playlists['user'][1]["playlist2"]['tracks'][0]['count'] //3.0
  </code></pre>
  
  <p>but I'm a bit confused as to how access all <code>playlists names for playlists</code> and all <code>artists for tracks in playlists</code> using any <code>iteration</code> tool.</p>
  
  <p>how can I do it?</p>