def build_tier_tree(devices):
 tier2children = defaultdict(set)
 for dev in devices:
  for tier in tiers_for_dev(dev):
   if (len(tier) > 1):
    tier2children[tier[0:(-1)]].add(tier)
   else:
    tier2children[()].add(tier)
 return tier2children

def build_tier_tree ( devices ) : tier2children = defaultdict ( set ) for dev in devices : for tier in tiers_for_dev ( dev ) : if ( len ( tier ) > 1 ) : tier2children [ tier [ 0 : ( - 1 ) ] ] . add ( tier ) else : tier2children [ ( ) ] . add ( tier ) return tier2children
construct the tier tree from the zone layout .