How to iterate & search in a dictionary?
<p>I've constructed a dictionary like this:</p>

<p>dir is:  </p>

<pre><code>{((2, 1), 'South', 1): set([((2, 2), 'South', 1)]), 
((1, 3), 'South', 1): set([((1, 4), 'South', 1)]), 
((5, 3), 'East', 1): set([((4, 3), 'North', 1)]), 
((2, 2), 'South', 1): set([((2, 3), 'East', 1)]),   
((4, 2), 'East', 1): set([((3, 2), 'East', 1)]), 
((1, 1), 'West', 1): set([((2, 1), 'South', 1)])}
</code></pre>

<p>I want to iterate thru this dictionary like this:</p>

<p>If I have <code>((2, 1), 'South', 1)</code> as a key, then I'd like to extract its value <code>set([((2,2),'South',1)])</code> and take this as a key and search thru and find its value and so on...</p>

<p>But I'm unable to construct a function for the same. I keep getting just one value and it goes in an infinite loop. I think I may be fetching the values the values incorrectly. Can someone please tell me how I can do this?</p>
