def is_empty ( self ) : return all ( isinstance ( c , ParseNode ) and c . is_empty for c in self . children )
python check if node is empty
Returns True if this node has no children or if all of its children are ParseNode instances and are empty .
def is_empty(self):
    """Returns True if this node has no children, or if all of its children are ParseNode instances
    and are empty.
    """
    return all(isinstance(c, ParseNode) and c.is_empty for c in self.children)