def _normalize_location(loc):
    """
    Return a dictionary that represents the given location. If it's already a
    dictionary it's returned as-is but if not we try different attributes to
    get the latitude (``latitude`` or ``lat``) and longitude (``longitude``,
    ``lng``, or ``lon``).
    """
    if isinstance(loc, dict):
        return loc

    d = {}
    # Try different attributes for each one
    guesses = {
        "latitude": ("latitude", "lat"),
        "longitude": ("longitude", "lng", "lon"),
    }
    for attr, ks in guesses.items():
        for k in ks:
            if hasattr(loc, k):
                d[attr] = float(getattr(loc, k))
                break

    return d