def traverse_hiearchy(service):
 accounts = service.management().accounts().list().execute()
 print_accounts(accounts)
 if accounts.get('items'):
  firstAccountId = accounts.get('items')[0].get('id')
  webproperties = service.management().webproperties().list(accountId=firstAccountId).execute()
  print_webproperties(webproperties)
  if webproperties.get('items'):
   firstWebpropertyId = webproperties.get('items')[0].get('id')
   profiles = service.management().profiles().list(accountId=firstAccountId, webPropertyId=firstWebpropertyId).execute()
   print_profiles(profiles)
   if profiles.get('items'):
    firstProfileId = profiles.get('items')[0].get('id')
    goals = service.management().goals().list(accountId=firstAccountId, webPropertyId=firstWebpropertyId, profileId=firstProfileId).execute()
    print_goals(goals)
 print_segments(service.management().segments().list().execute())

def traverse_hiearchy ( service ) : accounts = service . management ( ) . accounts ( ) . list ( ) . execute ( ) print_accounts ( accounts ) if accounts . get ( 'items' ) : firstAccountId = accounts . get ( 'items' ) [ 0 ] . get ( 'id' ) webproperties = service . management ( ) . webproperties ( ) . list ( accountId = firstAccountId ) . execute ( ) print_webproperties ( webproperties ) if webproperties . get ( 'items' ) : firstWebpropertyId = webproperties . get ( 'items' ) [ 0 ] . get ( 'id' ) profiles = service . management ( ) . profiles ( ) . list ( accountId = firstAccountId , webPropertyId = firstWebpropertyId ) . execute ( ) print_profiles ( profiles ) if profiles . get ( 'items' ) : firstProfileId = profiles . get ( 'items' ) [ 0 ] . get ( 'id' ) goals = service . management ( ) . goals ( ) . list ( accountId = firstAccountId , webPropertyId = firstWebpropertyId , profileId = firstProfileId ) . execute ( ) print_goals ( goals ) print_segments ( service . management ( ) . segments ( ) . list ( ) . execute ( ) )
traverses the management api hiearchy and prints results .