def null_safe(rule):
 def null_safe_rl(expr):
  result = rule(expr)
  if (result is None):
   return expr
  else:
   return result
 return null_safe_rl

def null_safe ( rule ) : def null_safe_rl ( expr ) : result = rule ( expr ) if ( result is None ) : return expr else : return result return null_safe_rl
return original expr if rule returns none .