We already have code to handle this in the cases where we remove buttons.
For example, if you consider the rich text editor when used to edit signatures, we do remove some buttons based on permissions there.
My attempted reproduction case was to set all permissions to never except "Allow images" and "Allow links".
[ATTACH=full]220486[/ATTACH]
I then modified the editor button configuration so that "Insert image" and "Insert link" were in a drop down, and I included only that drop down in the editor.
[ATTACH=full]220484[/ATTACH]
[ATTACH=full]220485[/ATTACH]
With the permissions as configured above:
[ATTACH=full]220487[/ATTACH]
With the permissions denying access to links and images:
[ATTACH=full]220488[/ATTACH]
It seems as though we correctly remove a dropdown that is empty.
So with that in mind, you need to adjust your code so the same thing happens.