from typing import Set


def possible_types(name: str) -> Set[str]:
    """Build a set of all possible types from a fully qualified name."""
    labels = name.split('.')
    label_count = len(labels)
    types = set()
    for count in range(label_count):
        parts = labels[label_count - count - 4 :]
        if not parts[0].startswith('_'):
            break
        types.add('.'.join(parts))
    return types