Searching an element in a list of double-nested dictionaries with generator
<p>I have a list of dictionaris. In every dictionary, i need to use values, which are in the dictionaries, which are in the dictionaries:</p>

<pre><code>[{'Cells': {'Address': 'ÐÐ¸Ð¶Ð½Ð¸Ð¹ ÐÐ¸ÑÐµÐ»ÑÐ½ÑÐ¹ Ð¿ÐµÑÐµÑÐ»Ð¾Ðº, Ð´Ð¾Ð¼ 3, ÑÑÑÐ¾ÐµÐ½Ð¸Ðµ 1',
   'AdmArea': 'Ð¦ÐµÐ½ÑÑÐ°Ð»ÑÐ½ÑÐ¹ Ð°Ð´Ð¼Ð¸Ð½Ð¸ÑÑÑÐ°ÑÐ¸Ð²Ð½ÑÐ¹ Ð¾ÐºÑÑÐ³',
   'District': 'ÐÐµÑÐ°Ð½ÑÐºÐ¸Ð¹ ÑÐ°Ð¹Ð¾Ð½',
   'IsNetObject': 'Ð½ÐµÑ',
   'Name': 'Ð®Ð½Ð¸Ð¾Ð½ ÐÐ¶ÐµÐº',
   'OperatingCompany': None,
   'PublicPhone': [{'PublicPhone': '(495) 621-19-63'}],
   'SeatsCount': 30,
   'SocialPrivileges': 'Ð½ÐµÑ',
   'geoData': {'coordinates': [37.62158794615201, 55.76536695660836],
    'type': 'Point'},
   'global_id': 20660594},
  'Id': 'ae3e9479-070f-4d66-9429-de3acd8427ac',
  'Number': 1},
 {'Cells': {'Address': 'Ð¿ÑÐ¾ÑÐ¿ÐµÐºÑ ÐÐ¸ÑÐ°, Ð´Ð¾Ð¼ 91, ÐºÐ¾ÑÐ¿ÑÑ 1',
   'AdmArea': 'Ð¡ÐµÐ²ÐµÑÐ¾-ÐÐ¾ÑÑÐ¾ÑÐ½ÑÐ¹ Ð°Ð´Ð¼Ð¸Ð½Ð¸ÑÑÑÐ°ÑÐ¸Ð²Ð½ÑÐ¹ Ð¾ÐºÑÑÐ³',
   'District': 'ÐÑÑÐ°Ð½ÐºÐ¸Ð½ÑÐºÐ¸Ð¹ ÑÐ°Ð¹Ð¾Ð½',
   'IsNetObject': 'Ð½ÐµÑ',
   'Name': 'ÐÐ°Ñ Â«ÐÐ¶Ð¾Ð½Ð½Ð¸ ÐÑÐ¸Ð½ ÐÐ°Ð±Â»',
   'OperatingCompany': None,
   'PublicPhone': [{'PublicPhone': '(495) 602-45-85'}],
   'SeatsCount': 50,
   'SocialPrivileges': 'Ð½ÐµÑ',
   'geoData': {'coordinates': [37.635709999611, 55.805575000159],
    'type': 'Point'},
   'global_id': 20660628},
  'Id': 'c5301186-00bb-4a1f-af03-6f3237292a51',
  'Number': 2},
</code></pre>

<p>I'm given coordinates <code>[lattitude, attitude]</code>. I want to find the smallest distance between given coordinates and coordinates in dictionaries. So i need to iterate over dictionaries and calculate the distance. 
I'am quite new, but i want to be more proffesional with using a generator to find the distance. But, using <code>__next__()</code>, will stop iterating as soon as it meets the condition, so i'am just dont if it is possible. </p>

<p><strong>So, to be short: What is the most efficient way to find the  smallest distance from a given spot in this data structure?</strong> </p>

<p>First, let's assume you have a function get_distance() which finds distance between two points with lat and long. I can describe it, but I think for now it is not the point of the question. Then, the code will be look like:</p>

<pre><code>cells = {...} # your data is here
point = [..] # coordinates of the point 
distances = {get_distance(point, cell['Cells']['geoData']['coordinates']): cell['Id'] for cell in cells}  # I don't know do you need a whole entry to be found or only `Id`
closest_id = distances[min(distances.keys())]
</code></pre>

<p>Off course it is only of possible solutions. I've made it with dict comprehension but sometimes it is more easy to rea to do it with suaul <code>for</code> loop. Please let me know if something is unclear.</p>

<p>If you also have problems with writing <code>get_distance</code> function - here is an one of examples: <a href="http://stackoverflow.com/questions/15736995/how-can-i-quickly-estimate-the-distance-between-two-latitude-longitude-points">How can I quickly estimate the distance between two (latitude, longitude) points?</a> (of course it needs to be modified a bit to look like get_distance function)</p>

python dictionary