def make_account_trees():
 for id in accounts.keys():
  account = accounts[id]
  if account.get(u'parent_id'):
   if accounts.get(account[u'parent_id']):
    accounts[account[u'parent_id']][account[u'name']] = account
   del account[u'parent_id']
   del account[u'name']
 for id in accounts.keys():
  if ((u'children' in accounts[id]) and (not accounts[id].get(u'children'))):
   del accounts[id][u'children']

def make_account_trees ( ) : for id in accounts . keys ( ) : account = accounts [ id ] if account . get ( u'parent_id' ) : if accounts . get ( account [ u'parent_id' ] ) : accounts [ account [ u'parent_id' ] ] [ account [ u'name' ] ] = account del account [ u'parent_id' ] del account [ u'name' ] for id in accounts . keys ( ) : if ( ( u'children' in accounts [ id ] ) and ( not accounts [ id ] . get ( u'children' ) ) ) : del accounts [ id ] [ u'children' ]
build tree hierarchy .