Fix the issue by applying the same flattening approach as for interstitials. To avoid repeatedly performing the same work, flattening is made once and the result cached.
Checklist
[x] APIs have been properly documented (if relevant).
[x] The documentation has been updated (if relevant).
[x] New unit tests have been written (if relevant).
Description
This PR fixes #861.
Changes made
Checklist