def BuildAndDisplayAdUnitTree(root_ad_unit, all_ad_units):
 tree = {}
 for ad_unit in all_ad_units:
  if ('parentId' in ad_unit):
   if (ad_unit['parentId'] not in tree):
    tree[ad_unit['parentId']] = []
   tree[ad_unit['parentId']].append(ad_unit)
 DisplayAdUnitTree(root_ad_unit, tree)

def BuildAndDisplayAdUnitTree ( root_ad_unit , all_ad_units ) : tree = { } for ad_unit in all_ad_units : if ( 'parentId' in ad_unit ) : if ( ad_unit [ 'parentId' ] not in tree ) : tree [ ad_unit [ 'parentId' ] ] = [ ] tree [ ad_unit [ 'parentId' ] ] . append ( ad_unit ) DisplayAdUnitTree ( root_ad_unit , tree )
create an ad unit tree and display it .