def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values):
 for d in reversed(accounts):
  if d.parent_account:
   for period in period_list:
    accounts_by_name[d.parent_account][period.key] = (accounts_by_name[d.parent_account].get(period.key, 0.0) + d.get(period.key, 0.0))
   accounts_by_name[d.parent_account][u'opening_balance'] = (accounts_by_name[d.parent_account].get(u'opening_balance', 0.0) + d.get(u'opening_balance', 0.0))

def accumulate_values_into_parents ( accounts , accounts_by_name , period_list , accumulated_values ) : for d in reversed ( accounts ) : if d . parent_account : for period in period_list : accounts_by_name [ d . parent_account ] [ period . key ] = ( accounts_by_name [ d . parent_account ] . get ( period . key , 0.0 ) + d . get ( period . key , 0.0 ) ) accounts_by_name [ d . parent_account ] [ u'opening_balance' ] = ( accounts_by_name [ d . parent_account ] . get ( u'opening_balance' , 0.0 ) + d . get ( u'opening_balance' , 0.0 ) )
accumulate childrens values in parent accounts .