<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_action(self, action, sub_menu='Advanced'):
 """ Adds an action to the editor's context menu. :param action: QAction to add to the context menu. :param sub_menu: The name of a sub menu where to put the action. 'Advanced' by default. If None or empty, the action will be added at the root of the submenu. """

        if sub_menu:
            try:
                mnu = self._sub_menus[sub_menu]
            except KeyError:
                mnu = QtWidgets.QMenu(sub_menu)
                self.add_menu(mnu)
                self._sub_menus[sub_menu] = mnu
            finally:
                mnu.addAction(action)
        else:
            self._actions.append(action)
        action.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.addAction(action)