sumUntil(end: number): number {
    invariant(
      0 <= end && end < this._size + 1,
      'Index out of range %s',
      end,
    );

    if (end === 0) {
      return 0;
    }

    let node = this._half + end - 1;
    let sum = this._heap[node];
    for (; node !== 1; node = parent(node)) {
      if (node % 2 === 1) {
        sum += this._heap[node - 1];
      }
    }

    return sum;
  }
Returns the sum get(0) + get(1) + ... + get(end - 1).