To reproduce it:
1) Install a fresh Geoserver 2.14
2) Create a layer group with name childgroup in workspace topp, adding 2 of the layers, set the mode to Container Tree
3) Create second a layer group with name parentgroup in workspace topp, adding the layer group created in 2), set the mode to Container Tree
4) Delete the layer group parentgroup, seem also deleted the childgroup layer group, I guess due to the mode Container Tree
5) Go to workspaces and try to delete workspace topp, when clicking ok a javacript confirm dialog is displayed, that should not be displayed. The only way to continue is to click Leave and then an error page is displayed and no way to proceed. Prevents also other actions like deleting other workspaces.
7) Restarting GeoServer and going to layergroups the layer group childgroup is listed (in step 4 seemed removed also) and now can be deleted without error, also the workspace topp.
Seem step 4) leaves GeoServer in some inconsistent status.
With the REST API, you get similar issue.
Using the REST API, I've checked to delete first childgroup layer group and after parentgroup layer group, but I get the following error:
Unable to delete layer group referenced by layer group 'GROUP_PARENT'
If I try to update the parentgroup layer group to empty it, I get this other error:
Layer group must not be empty
I got a workaround with the REST API, setting the mode of the layer groups to Single and then delete them, that allows to delete them and avoids also the error described. But it's kind of a hack.
Tested in OSX and Windows with GeoServer 2.13 and 2.14.
Also with 2.9 version, but no problem there.