Explode nested blocks recursively

Hi to All.

I have a problem to solve.

I need to create a python script that explodes my “nested” blocks leaving the “main” blocks intact

Example:

I have a block: (“bl_main_001”)
Nested inside “bl_main_001” there are two other blocks: (“bl_nest_001”, “bl_nest_002”).
In addition “bl_nest_002” has a nested block: (“bl_nest_nest_001”)

I would like the script to return me only one “main block 001” and that there are no nested blocks in the file.
A stupid test file

block explode example (1).3dm (78.7 KB)

thanks to those who will try to help me :slight_smile: