@SuppressWarnings("unchecked")
  private void expandEntries(final int nextSize) {
    var nextEntries = (T[]) Array.newInstance(entries.getClass().getComponentType(), nextSize);
    System.arraycopy(entries, 0, nextEntries, 0, currentCapacity);
    entries = nextEntries;
    currentCapacity = nextSize;
  }
Trims the "middle" section of items out of the stack. Items below the cutpoint remains, and of
the items above only the itemsToKeep items remain. All items in the middle are removed.

@param cutPoint Point at which to start removing items
@param itemsToKeep itemsToKeep Number of items on top to place at the cutPoint
@throws IllegalArgumentException if the cutPoint or items to keep is negative.
@throws UnderflowException If there are less than itemsToKeep above the cutPoint
evm/src/main/java/org/hyperledger/besu/evm/internal/FlexStack.java