def VisitUnionType(self, union):
    c = collections.Counter()
    for t in set(union.type_list):
        if isinstance(t, pytd.GENERIC_BASE_TYPE):
            c += collections.Counter(self.hierarchy.ExpandSubClasses(str(t)))
    new_type_list = [t for t in union.type_list if (c[str(t)] <= 1)]
    return pytd_utils.JoinTypes(new_type_list)
def VisitUnionType(self, union):
    c = collections.Counter()
    for t in set(union.type_list):
        if isinstance(t, pytd.GENERIC_BASE_TYPE):
            c += collections.Counter(self.hierarchy.ExpandSubClasses(str(t)))
    new_type_list = [t for t in union.type_list if (c[str(t)] <= 1)]
    return pytd_utils.JoinTypes(new_type_list)