def get_hashtag_counts(key, val, collection):
    """
    Returns a dict of the region from the colletion.

    For states, you receive a document containing keys:

        'name', 'fips', 'counts', 'abbrev', 'landarea'

    The value associated to 'counts' is a dict of hashtag and hashtag counts.
    Query by: 'name', 'fips', or 'abbrev'.

    For counties, you receive a document containing keys:

        'name', 'state_fips', 'county_fips', 'geoid', 'landarea'

    Etc.


    Examples:

        hashtag_counts_by_state('name', 'Washington', collection)
        hashtag_counts_by_state('fips', 53, collection)
        hashtag_counts_by_state('abbrev', 'WA', collection)

    """
    c = collection.find({key: val})
    hashtag_counts = {}
    first = True
    for doc in c:
        if first:
            hashtag_counts.update(doc)
            first = False
        else:
            # After the first one, we must explictly update the inner dict.
            hashtag_counts['counts'].update(doc['counts'])
    return hashtag_counts