title: How do I traverse and search a python dictionary?
body: <p>I have nested dictionaries:</p>
  <pre><code>{'key0': {'attrs': {'entity': 'p', 'hash': '34nj3h43b4n3', 'id': '4130'},
            u'key1': {'attrs': {'entity': 'r',
                                'hash': '34njasd3h43b4n3',
                                'id': '4130-1'},
                      u'key2': {'attrs': {'entity': 'c',
                                          'hash': '34njasd3h43bdsfsd4n3',
                                          'id': '4130-1-1'}}},
            u'key3': {'attrs': {'entity': 'r',
                                'hash': '34njasasasd3h43b4n3',
                                'id': '4130-2'},
                      u'key4': {'attrs': {'entity': 'c',
                                          'hash': '34njawersd3h43bdsfsd4n3',
                                          'id': '4130-2-1'}},
                      u'key5': {'attrs': {'entity': 'c',
                                          'hash': '34njawersd3h43bdsfsd4n3',
                                          'id': '4130-2-2'}}}},
   'someohterthing': 'someothervalue',
   'something': 'somevalue'}
                                                              
        
  </code></pre>
  <p>given an <code>id</code>  - one of all the <code>ids</code> like <code>4130</code> to <code>4130-2-2</code>.<br />
  whats the easiest way to navigate to the correct dictionary?</p>
  <p>If the given <code>id</code> is <code>4130-2-1</code> then it should reach the dictionary with <code>key=key5</code>.</p>
  <p>No XML approaches please.</p>
  <p><strong>Edit(1):</strong> The nesting is between <code>1</code> to <code>4</code> levels, but I know the nesting before I parse.</p>
  <p><strong>Edit(2)</strong>: Fixed the code.</p>
  <p><strong>Edit(3)</strong>: Fixed code again for string values of <code>ids</code>. Please excuse for the confusion created. This is final I hope :)</p>