public static OptionalInt findHighestKnownBlockIndex(
      final Blockchain blockchain,
      final List<BlockHeader> headers,
      final boolean ascendingHeaderOrder) {
    final int offset = ascendingHeaderOrder ? -1 : 0;
    final Comparator<BlockHeader> comparator =
        knownBlockComparator(blockchain, ascendingHeaderOrder);

    final int insertionIndex = -Collections.binarySearch(headers, null, comparator) - 1;
    final int ancestorIndex = insertionIndex + offset;
    if (ancestorIndex < 0 || ancestorIndex >= headers.size()) {
      return OptionalInt.empty();
    }
    return OptionalInt.of(ancestorIndex);
  }
General utility to process a list of headers and a blockchain, sussing out which header in the
input list is simultaneously the highest order block number and a direct match with one of the
headers of the local chain. The purpose of which being to determine the point of departure in
fork scenarios.

@param blockchain our local copy of the blockchain
@param headers the list of remote headers
@param ascendingHeaderOrder whether the headers are sorted in ascending or descending order
@return index of the highest known header, or an empty value if no header is known
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/util/BlockchainUtil.java