only recusively delete modules if all their parents are marked for delet...

...ion (PLAT-333)

@dmitchell , may you please take a first look? I changed the tests a bit, and and added a management command. But otherwise the change is quite small
`has_item` throughout