import tokenize


def is_name_token(token, name):
    """Check if a token is a NAME and has a specific string value

    NAME tokens are returned by the ``tokenize`` module for identifiers
    and keywords: ``if``, ``lambda``, ``a_variable``, ``is_name_token``, ...

    Arguments:
        token (tokenize.TokenInfo): The Token to check.
        name (Union[str, Iterable[str]]): A token name or names to check
                                          against; must be lowercase.

    Returns:
        Return ``True`` if token is a ``NAME`` token and case-insensitively
        matches ``name``. If ``name`` is a tuple or set, return ``True`` if the
        token matches any of the supplied names.

        Return ``False`` otherwise.
    """

    if isinstance(name, str):
        name = set([name])
    return token.exact_type == tokenize.NAME and token.string.lower() in name