Deleting nested blocks leaves blocks named "UnNamed block reference"

I am working on a script to delete certain nested layers come with files exported from Creo. I can delete the nested blocks but the blocks remain as “UnNamed block reference”. Is there a way to remove these blocks?