def _match_region(self, name, position):
    rect = self.regions['regions'][name]['pos1'], self.regions['regions'][name
        ]['pos2']
return all(self.point_inside(rect, position))
if self.last_region and self._match_region(self.last_region, position):
    self.code_to_run_when_match(position)
return
for name in self.regions['regions']:
    if self._match_region(name, position):
        self.last_region = name
self.code_to_run_when_match(position)
return
return
Запустите словарь для цикла с определенным значением ключа