parameters: (self)
return_statement: return self
docstring: Optimize certain stacked wildcard patterns.
docstring_summary: Optimize certain stacked wildcard patterns.
docstring_tokens: Optimize certain stacked wildcard patterns .
function: def optimize(self):
          """Optimize certain stacked wildcard patterns."""
          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
function_tokens: 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