This has been a TODO since #4468
Comments in the code to make it (hopefully) understandable.
Please review/test. Thank you.
This is possibly still work in progress... needing to understand GetLocator in more detail, it may be that the best two options are to GetLocator(chainActive.Tip()) or GetLocator(pindexBestHeader). I'm also not assuming that chainActive.Tip() isn't always an ancestor of pindexBestHeader (based on the "TODO: optimize" comment that was made in #4468).