Simplifying layer structure by merging

After reading There is a block definition on layer X, delete it before deleting layer , I want to bring to others’ attention, MergeLayer, a method that exists in RhinoScript but doesn’t appear to be in the UI. This method has been quite valuable to me for simplifying layer structures, those either created by me or by others (typically imported from another CAD system), with or without blocks.

I just wrote a more robust version in RhinoPython and wanted to share: (5.1 KB)
(rhinoscriptsyntax doesn’t contain MergeLayer, but it easy to replicate its behavior.)

A MergeLayer command has been requested a few of times in this forum, but I didn’t find an issue for it in YouTrack.