After some extra digging I found your script that does the job sufficiently!
If somebody uses the script: you have to put all new layers on a parent layer before merging them to the old ones, and it doesn’t go deeper than one sublayer.
MergeMatchingLayers.py (3.6 KB)
Thanks again John