'Remove empty dict nodes in the callback stack.
:param str or int prefix: The prefix for keeping track of callbacks with
:param str key: The callback key'

def _cleanup_callback_dict(self, prefix, key=None):

    if (key and (key in self._stack[prefix]) and (not self._stack[prefix][key])):
        del self._stack[prefix][key]
    if ((prefix in self._stack) and (not self._stack[prefix])):
        del self._stack[prefix]
