code: @SuppressWarnings("unchecked")
      public static <Data extends AbstractKVStorable> Data[] merge(Data[] toAdd) {
          if (toAdd.length == 1) {
              return toAdd;
          }
          // estimate the number of unique elements and check the precondition, that the array must been sorted
          int count = 1;
          for (int i = 0; i < toAdd.length - 1; i++) {
              int compare = KeyUtils.compareKey(toAdd[i].key, toAdd[i + 1].key);
              if (compare > 0) {
                  throw new RuntimeException("The given array is not sorted.");
              } else if(compare < 0) {
                  count++;
              } else { // if compare == 0
                  // do nothing, elements are equal
              }
          }
  
          AbstractKVStorable[] realToAdd = new AbstractKVStorable[count];
          count = 0;
          // merge Elements in toAdd
          AbstractKVStorable first = toAdd[0];
          for (int k = 1; k < toAdd.length; k++) {
              while (k < toAdd.length && KeyUtils.compareKey(toAdd[k].key, first.key) == 0) {
                  first = first.merge(toAdd[k]);
                  k++;
              }
              realToAdd[count++] = first;
              if (k < toAdd.length) {
                  first = toAdd[k];
              }
          }
  
          if (count < realToAdd.length && KeyUtils.compareKey(realToAdd[realToAdd.length - 2].key, first.key) != 0) {
              realToAdd[count++] = first;
          }
          return (Data[]) realToAdd;
      }
docs: This method merges all {@link AbstractKVStorable}s in the given array with same keys. The array must been sorted.
  
  @param toAdd
  this array might contain duplicate entries concerning the key, which must be merged.
  
  @return a new array containing unique {@link AbstractKVStorable}s. The array is sorted.