def DisplayTree(node, children, level=0):
 value = ''
 node_type = ''
 if ('caseValue' in node):
  case_value = node['caseValue']
  node_type = case_value['ProductDimension.Type']
  if (node_type == 'ProductCanonicalCondition'):
   value = (case_value['condition'] if ('condition' in case_value) else 'OTHER')
  elif (node_type == 'ProductBiddingCategory'):
   value = ('%s(%s)' % (case_value['type'], (case_value['value'] if ('value' in case_value) else 'OTHER')))
  else:
   value = (case_value['value'] if ('value' in case_value) else 'OTHER')
 print ('%sid: %s, node_type: %s, value: %s\n' % ((' ' * level), node['id'], node_type, value))
 for child_node in children[node['id']]:
  DisplayTree(child_node, children, (level + 1))

def DisplayTree ( node , children , level = 0 ) : value = '' node_type = '' if ( 'caseValue' in node ) : case_value = node [ 'caseValue' ] node_type = case_value [ 'ProductDimension.Type' ] if ( node_type == 'ProductCanonicalCondition' ) : value = ( case_value [ 'condition' ] if ( 'condition' in case_value ) else 'OTHER' ) elif ( node_type == 'ProductBiddingCategory' ) : value = ( '%s(%s)' % ( case_value [ 'type' ] , ( case_value [ 'value' ] if ( 'value' in case_value ) else 'OTHER' ) ) ) else : value = ( case_value [ 'value' ] if ( 'value' in case_value ) else 'OTHER' ) print ( '%sid: %s, node_type: %s, value: %s\n' % ( ( ' ' * level ) , node [ 'id' ] , node_type , value ) ) for child_node in children [ node [ 'id' ] ] : DisplayTree ( child_node , children , ( level + 1 ) )
recursively display a node and each of its children .