'Optimize certain stacked wildcard patterns.'

def optimize(self):

    subpattern = None
    if ((self.content is not None) and (len(self.content) == 1) and (len(self.content[0]) == 1)):
        subpattern = self.content[0][0]
    if ((self.min == 1) and (self.max == 1)):
        if (self.content is None):
            return NodePattern(name=self.name)
        if ((subpattern is not None) and (self.name == subpattern.name)):
            return subpattern.optimize()
    if ((self.min <= 1) and isinstance(subpattern, WildcardPattern) and (subpattern.min <= 1) and (self.name == subpattern.name)):
        return WildcardPattern(subpattern.content, (self.min * subpattern.min), (self.max * subpattern.max), subpattern.name)
    return self
