code: private void buildCoverTree() {
          ArrayList<DistanceSet> pointSet = new ArrayList<>();
          ArrayList<DistanceSet> consumedSet = new ArrayList<>();
  
          E point = data[0];
          int idx = 0;
          double maxDist = -1;
  
          for (int i = 1; i < data.length; i++) {
              DistanceSet set = new DistanceSet(i);
              double dist = distance.d(point, data[i]);
              set.dist.add(dist);
              pointSet.add(set);
              if (dist > maxDist) {
                  maxDist = dist;
              }
          }
  
          root = batchInsert(idx, getScale(maxDist), getScale(maxDist), pointSet, consumedSet);
      }
docs: Builds the cover tree.