code: def avl_join(t1, t2, node):
      if DEBUG_JOIN:
          print('-- JOIN node=%r' % (node,))
      if t1 is None and t2 is None:
          if DEBUG_JOIN:
              print('Join Case 1')
          top = node
      elif t1 is None:
          if DEBUG_JOIN:
              print('Join Case 2')
          top = avl_insert_dir(t2, node, 0)
      elif t2 is None:
          if DEBUG_JOIN:
              print('Join Case 3')
          top = avl_insert_dir(t1, node, 1)
      else:
          h1 = height(t1)
          h2 = height(t2)
          if h1 > h2 + 1:
              if DEBUG_JOIN:
                  print('Join Case 4')
              top = avl_join_dir_recursive(t1, t2, node, 1)
              if DEBUG_JOIN:
                  ascii_tree(t1, 'top')
          elif h2 > h1 + 1:
              if DEBUG_JOIN:
                  print('Join Case 5')
                  ascii_tree(t1)
                  ascii_tree(t2)
              top = avl_join_dir_recursive(t1, t2, node, 0)
              if DEBUG_JOIN:
                  ascii_tree(top)
          else:
              if DEBUG_JOIN:
                  print('Join Case 6')
              top = avl_new_top(t1, t2, node, 0)
      return top