code: private int dfs(int[][] merge, int index, int[] order, int i) {
          int n = merge.length + 1;
  
          if (merge[index][0] > merge.length) {
              i = dfs(merge, merge[index][0] - n, order, i);
          } else {
              order[i++] = merge[index][0];
          }
  
          if (merge[index][1] > merge.length) {
              i = dfs(merge, merge[index][1] - n, order, i);
          } else {
              order[i++] = merge[index][1];
          }
  
          return i;
      }
docs: DFS the tree to find the order of leafs to avoid the cross of lines in
  the plot.