def _crawl(expr, func, *args, **kwargs):
 val = func(expr, *args, **kwargs)
 if (val is not None):
  return val
 new_args = (_crawl(arg, func, *args, **kwargs) for arg in expr.args)
 return expr.func(*new_args)

def _crawl ( expr , func , * args , ** kwargs ) : val = func ( expr , * args , ** kwargs ) if ( val is not None ) : return val new_args = ( _crawl ( arg , func , * args , ** kwargs ) for arg in expr . args ) return expr . func ( * new_args )
crawl the expression tree .