pyebnf/primitive.py
def trimmed(self, pred=trimmed_pred_default):
    """Trim a ParseTree.

    A node is trimmed if pred(node) returns True.
    """
    new_children = []

    for child in self.children:
      if isinstance(child, ParseNode):
        new_child = child.trimmed(pred)
      else:
        new_child = child

      if not pred(new_child, self):
        new_children.append(new_child)

    return ParseNode(self.node_type,
                     children=new_children,
                     consumed=self.consumed,
                     position=self.position,
                     ignored=self.ignored)
def trimmed(self, pred=trimmed_pred_default):
    new_children = []

    for child in self.children:
      if isinstance(child, ParseNode):
        new_child = child.trimmed(pred)
      else:
        new_child = child

      if not pred(new_child, self):
        new_children.append(new_child)

    return ParseNode(self.node_type,
                     children=new_children,
                     consumed=self.consumed,
                     position=self.position,
                     ignored=self.ignored)
def trimmed ( self , pred = trimmed_pred_default ) : new_children = [ ] for child in self . children : if isinstance ( child , ParseNode ) : new_child = child . trimmed ( pred ) else : new_child = child if not pred ( new_child , self ) : new_children . append ( new_child ) return ParseNode ( self . node_type , children = new_children , consumed = self . consumed , position = self . position , ignored = self . ignored )
Trim a ParseTree.

    A node is trimmed if pred(node) returns True.
Trim a ParseTree .