def _find_predicates(expr):
 if (not isinstance(expr, BooleanFunction)):
  return {expr}
 return set().union(*(_find_predicates(i) for i in expr.args))

def _find_predicates ( expr ) : if ( not isinstance ( expr , BooleanFunction ) ) : return { expr } return set ( ) . union ( * ( _find_predicates ( i ) for i in expr . args ) )
helper to find logical predicates in booleanfunctions .