private Optional<PendingTransaction> getNextOptional(
          final Iterator<PendingTransaction> pendingTxsIterator) {
        return pendingTxsIterator.hasNext()
            ? Optional.of(pendingTxsIterator.next())
            : Optional.empty();
      }
See this post for an explainer about these data structures:
https://hackmd.io/@adietrichs/1559-transaction-sorting
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java