def improve_location(location):
    """
    Heuristically compensate for anomalies from upstream OSM.

    TODO:
    - Get urban vs. rural sorted out

        1. country
        2. state
        3. "Überregional": "q-region"
            - county, state_district, state
        4. "Regional": "q-hood"
            - neighbourhood vs. quarter vs. residential vs. suburb vs. city_district vs. city vs. allotments

    - How to handle "building", "public_building", "residential", "pedestrian", "kindergarten", "clothes"?
    - Also check OSM place: https://wiki.openstreetmap.org/wiki/Key:place !!!
    """
    if location is None:
        return
    address = location.address
    if 'country_code' in address:
        address.country_code = address.country_code.upper()
    if 'country_code' in address:
        if address.country_code == 'DO':
            address.country = 'Dominican Republic'
        if address.country_code == 'PL':
            address.country = 'Poland'
    stadtstaaten = ['Berlin', 'Bremen', 'Hamburg', 'Wien']
    city_or_state = address.get('city', address.get('state'))
    if city_or_state in stadtstaaten:
        address.state = address.city = city_or_state
    city_choices = ['village', 'town', 'county', 'suburb', 'city_district',
        'state']
    if 'city' not in address:
        for fieldname in city_choices:
            if fieldname in address:
                address.city = address[fieldname]
                break
    if 'city' in address and address.city == 'Rgbg':
        address.city = 'Regensburg'
    if 'city' not in address:
        address.city = 'Unknown city'
    if 'suburb' not in address and 'residential' in address:
        address.suburb = address.residential
    if 'suburb' not in address and 'neighbourhood' in address:
        address.suburb = address.neighbourhood
    if 'road' not in address:
        road_choices = ['path', 'pedestrian', 'cycleway', 'footway',
            'neighbourhood', 'house_number']
        for fieldname in road_choices:
            if fieldname in address:
                address.road = address[fieldname]
                break
    if 'road' not in address:
        address.road = 'Unknown road'
