I think .unfold could be helpful. Have a look at this post and let me know if you could adapt it to your use case.
.unfold