private static Comparator<BlockHeader> knownBlockComparator(
      final Blockchain blockchain, final boolean ascendingHeaderOrder) {
    final Comparator<BlockHeader> comparator =
        (final BlockHeader element0, final BlockHeader element1) -> {
          if (element0 == null) {
            return blockchain.contains(element1.getHash()) ? -1 : 1;
          }
          return blockchain.contains(element0.getHash()) ? 1 : -1;
        };
    return ascendingHeaderOrder ? comparator.reversed() : comparator;
  }
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