The use case was multiple states within the same Lifecycle that are considered “release states".
The objective was to recursively, which is what you're looking for, display the released structure.
The definition of released structure in this case was the latest iteration that is at any of states considered to be a "released" state. If none are at a released state include the latest iteration.
The filter could certainly have excluded anything that was never released but, hey, I just do what I'm told.
We keyed off the state but one can key off anything including any attribute value.
It works like this.
OOTB by default structured displayed is the latest rev.iteration.
The user selects a custom action that builds the structure filter per the spec. And yes, the spec is built recursively through all levels of the structure.
Then they select the filter and display the structure per the spec.
In this example the two states I was using to simulate the released states were Released and In Progress. Yeah, I know In Progress doesn't sound like released but it's just an example of filtering by state.
So, this is very doable.
Seems to be bombproof too.
Now that I've written the code to do it it would not take much to edit the code to filter by any other attribute.