from typing import Union
from typing import Optional
from typing import Iterable


def __to_string(tag: Union[str, list, None]) -> Optional[str]:
    """
    Function to turn a tag into a string.
    :param tag: the tag.
    :return: the tag as a string.
    """
    if isinstance(tag, str):
        res = tag.strip()
    elif isinstance(tag, Iterable):
        res = ', '.join(tag).strip()
    else:
        res = None
    if isinstance(res, str):
        return res or None
    return None