def prettydict(d):
 keys = sorted(list(d.keys()), key=get_max_denom, reverse=True)
 result = ''
 for tup in keys:
  children = sorted(d[tup], key=get_max_denom, reverse=False)
  result += (prettytuple(tup) + '\n')
  for child in children:
   result += (('  ' + prettytuple(child)) + '\n')
 return result

def prettydict ( d ) : keys = sorted ( list ( d . keys ( ) ) , key = get_max_denom , reverse = True ) result = '' for tup in keys : children = sorted ( d [ tup ] , key = get_max_denom , reverse = False ) result += ( prettytuple ( tup ) + '\n' ) for child in children : result += ( ( '  ' + prettytuple ( child ) ) + '\n' ) return result
print keys of a dictionary with children indented underneath .