I would warn this is potentially a dangerous script since it can delete items which are supposed to be there. Some custom scripts (and stock scripts, depending on what emulator you use), use internal items to hold/serialize data and do not have a parent entity. Deleting these will cause a loss...