def flatten_errors(cfg, res, levels=None, results=None):
 if (levels is None):
  levels = []
  results = []
 if (res == True):
  return results
 if ((res == False) or isinstance(res, Exception)):
  results.append((levels[:], None, res))
  if levels:
   levels.pop()
  return results
 for (key, val) in res.items():
  if (val == True):
   continue
  if isinstance(cfg.get(key), dict):
   levels.append(key)
   flatten_errors(cfg[key], val, levels, results)
   continue
  results.append((levels[:], key, val))
 if levels:
  levels.pop()
 return results

def flatten_errors ( cfg , res , levels = None , results = None ) : if ( levels is None ) : levels = [ ] results = [ ] if ( res == True ) : return results if ( ( res == False ) or isinstance ( res , Exception ) ) : results . append ( ( levels [ : ] , None , res ) ) if levels : levels . pop ( ) return results for ( key , val ) in res . items ( ) : if ( val == True ) : continue if isinstance ( cfg . get ( key ) , dict ) : levels . append ( key ) flatten_errors ( cfg [ key ] , val , levels , results ) continue results . append ( ( levels [ : ] , key , val ) ) if levels : levels . pop ( ) return results
an example function that will turn a nested dictionary of results into a flat list .