def _hash_token(application, token):
    """Creates a hashable object for given token then we could use it as a
    dictionary key.
    """
    if isinstance(token, dict):
        hashed_token = tuple(sorted(token.items()))
    elif isinstance(token, tuple):
        hashed_token = token
    else:
        raise TypeError('%r is unknown type of token' % token)
    return application.__class__.__name__, application.name, hashed_token
