Contour data structure output logic?

I have asked myself the very same question a couple of weeks ago, solved like this, maybe it can be helpful

[edit] looking at your screenshot, I would replace the Trim Tree component with a Path Mapper:
{A;B;C;D;E;F;G} → {F}