def _pick_error(log_interpretation):
 def yield_errors():
  for log_type in ('step', 'history', 'task'):
   errors = log_interpretation.get(log_type, {}).get('errors')
   for error in (errors or ()):
    (yield error)
 errors = _merge_and_sort_errors(yield_errors())
 if errors:
  return errors[0]
 else:
  return None

def _pick_error ( log_interpretation ) : def yield_errors ( ) : for log_type in ( 'step' , 'history' , 'task' ) : errors = log_interpretation . get ( log_type , { } ) . get ( 'errors' ) for error in ( errors or ( ) ) : ( yield error ) errors = _merge_and_sort_errors ( yield_errors ( ) ) if errors : return errors [ 0 ] else : return None
pick most recent error from a dictionary possibly containing step .