@Override
    public String toString() {
      return "Directories{" +
        "root=" + Arrays.toString(root) +
        ", leaves=" + Arrays.toString(leaves) +
        ", numLeaves=" + numLeaves +
        ", leafSize=" + leafSize +
        ", numAttempts=" + numAttempts +
        '}';
    }
Serialize all entries into bytes, choosing the # of leaf directories to ensure the header+root fits in 16 KB.

@param entries a sorted ObjectArrayList of all entries in the tileset.
@return byte arrays of the root and all leaf directories, and the # of leaves.
@throws IOException if compression fails
planetiler-core/src/main/java/com/onthegomap/planetiler/pmtiles/WriteablePmtiles.java