This gives us an option for failover of logical replication in 9.6, even if it's a bit cumbersome and complex for the client, in case failover slots don't make the cut. And, of course, it's a pre-req for failover slots, which I'll rebase on top of it shortly.
Andres, I tried to address your comments as best I could. The main one that I think stayed open was about the loop that finds the last timeline on a segment. If you think that's better done by directly scanning the List* of timeline history entries I'm happy to prep a follow-up.