What's the most reliable way to remove a layer and all its contents?

I was surprised by the fact that calling delete() on a group doesn’t remove the group’s contents recursively too.

Am I missing a method, or an option I can pass to delete() to specify that I want to delete also its contents recursively? If this doesn’t exist, why? It looks like this would be a very common operation.

I switched to this delete() method from batchPlay(), which seemed to be deleting all the group’s contents (which is what I want), just to realise that I introduced a bug in the process. I can implement a recursive function myself, but it looks like I’m doing something a basic API should provide!