@Marc'Antonio Alessi:
I am not sure if this qualifies as a negative effect but your code will update a block definition for every insert it encounters. If the main block "A" contains 10 inserts "B", the "B" block definition will be updated 10 times. To make the code more efficient consider using some sort of doneBlockNameList.
Or work with a blockNameList and an index. For every insert check if the name is already part of the blockNameList, if not append it. And just work through the list while raising the index.