def METHOD_NAME(location_type, record: dict) -> Optional[str]:
    """Dictionary key order impacts Elasticsearch behavior!!!"""
    if record[f"{location_type}_state_code"] is None:
        return None
    return json.dumps(
        {
            "country_code": record[f"{location_type}_country_code"],
            "state_code": record[f"{location_type}_state_code"],
            "state_name": record[f"{location_type}_state_name"],
            "population": record[f"{location_type}_state_population"],
        }
    )