Set of all wildcard names occurring in the pattern

def wc_names(self):
        """Set of all wildcard names occurring in the pattern"""
        if self.wc_name is None:
            res = set()
        else:
            res = set([self.wc_name])
        if self.args is not None:
            for arg in self.args:
                if isinstance(arg, Pattern):
                    res.update(arg.wc_names)
        if self.kwargs is not None:
            for val in self.kwargs.values():
                if isinstance(val, Pattern):
                    res.update(val.wc_names)
        return res