from typing import Set


def tagify(tail=u'', head=u'', sep=u'.'):
    """
    Returns namespaced event tag string.
    Tag generated by joining with sep the head and tail in that order
    head and tail may be a string or a list, tuple, or Set of strings

    If head is a list, tuple or Set Then
        join with sep all elements of head individually
    Else
        join in whole as string prefix

    If tail is a list, tuple or Set Then
        join with sep all elements of tail individually
    Else
        join in whole as string suffix

    If either head or tail is empty then do not exhibit in tag

    """
    if isinstance(head, (list, tuple, Set)):  # list like so expand
        parts = list(head)
    else:  # string like so put in list
        parts = [head]
    if isinstance(tail, (list, tuple, Set)):  # listlike so extend parts
        parts.extend(tail)
    else:  # string like so append
        parts.append(tail)
    return sep.join([part for part in parts if part])