In reply to Joost de Valk.

Maybe you'll have more luck with a Breadcrumbs block. For my own Full Site Editing theme ( Fizzie ) I needed a breadcrumbs block. I started writing my own then realised it would be much easier to call your function if it was available. I've just implemented on blocks.wp-a2z.org