def METHOD_NAME(self):
    menu = QMenu()
    new_group_action = menu.addAction(self.tr("Create a new group"))
    new_group_action.setIcon(QIcon.fromTheme("list-add"))
    new_group_action.triggered.connect(self.on_new_group_action_triggered)
    item = self.model().getItem(self.indexAt(self.context_menu_pos))
    selected_items = [self.model().getItem(index) for index in self.selectionModel().selectedIndexes()]
    selected_protocols = [item.protocol for item in selected_items if not item.is_group]
    self.move_to_group_actions.clear()
    if item.is_group:
        delete_group_action = menu.addAction(self.tr("Delete group"))
        delete_group_action.setIcon(QIcon.fromTheme("list-remove"))
        delete_group_action.triggered.connect(self.on_delete_group_action_triggered)
    elif item != self.model().rootItem:
        tree_items = self.model().protocol_tree_items
        other_groups = [i for i in tree_items.keys() if item not in tree_items[i]]
        if len(selected_protocols) > 0:
            menu.addSeparator()
            close_action = menu.addAction(self.tr("Close"))
            close_action.setIcon(QIcon.fromTheme("window-close"))
            close_action.triggered.connect(self.on_close_action_triggered)
        if len(other_groups) > 0:
            move_to_group_menu = menu.addMenu("Move to Group")
            for i in other_groups:
                group_name = self.model().rootItem.child(i).data()
                move_to_group_action = move_to_group_menu.addAction(group_name)
                move_to_group_action.triggered.connect(self.on_move_to_group_action_triggered)
                self.move_to_group_actions[move_to_group_action] = i
    if item != self.model().rootItem:
        menu.addSeparator()
        sort_group_elements_action = menu.addAction("Sort Group Elements")
        sort_group_elements_action.setIcon(QIcon.fromTheme("view-sort-ascending"))
        sort_group_elements_action.triggered.connect(self.on_sort_group_elements_action_triggered)
    return menu