def flatten_get_parameters(request):
    """Return a dict with flattened GET parameters.

    Otherwise a dict(ImmutableMultiDict) returns a list for each
    parameter value and that is not what we want in most of the cases.
    """
    if not hasattr(request, 'args'):
        return {}
    return {k: len(v) == 1 and v[0] or v
            for k, v in dict(request.args).items()}