def is_top_menu(self, widget):
        """Return True if widget is a top menu.

        widget (either a menu.submenu.main.Menu or
                menu.command.Command instance)

        A top menu is a widget which has children and whose
        parent is the MenuManager instance (the root of the
        whole menu structure).
        """
        ### evaluate conditions

        a = hasattr(widget, "children")
        b = isinstance(widget.parent, self.__class__)

        ### return True if both conditions are True
        return a and b
Return True if widget is a top menu.

        widget (either a menu.submenu.main.Menu or
                menu.command.Command instance)

        A top menu is a widget which has children and whose
        parent is the MenuManager instance (the root of the
        whole menu structure).
        
nodezator/menu/behaviour.py