def create_menus(workbench, menu_items, action_items):
    """ Create the WorkbenchMenu objects for the menu bar.

    This is the only external public API of this module.

    Parameters
    ----------
    workbench : Workbench
        The workbench object which is creating the menus.

    menu_items : list
        The list of all MenuItem objects to include in the menus. The
        order of the items in this list is irrelevant.

    action_items : list
        The list of all ActionItem objects to include in the menus.
        The order of the items in this list is irrelevant.

    Returns
    -------
    result : list
        An ordered list of Menu objects which can be directly included
        into the main window's MenuBar.

    """
    # create the nodes for the menu items
    menu_nodes = []
    for item in menu_items:
        node = MenuNode(item=item)
        menu_nodes.append(node)

    # assemble the menu nodes into a tree structure in two passes
    # in order to maintain the relative item definition order
    root = RootMenuNode()
    node_map = {u'/': root}
    for node in menu_nodes:
        path = node.path
        if path <= node_map:
            msg = "a menu item already exist for path '%s'"
            raise ValueError(msg % path)
        node_map[path] = node
    for node in menu_nodes:
        parent_path = node.parent_path
        if parent_path not in node_map:
            msg = "the path '%s' does not point to a menu item"
            raise ValueError(msg % parent_path)
        parent = node_map[parent_path]
        parent.children.append(node)

    # create the nodes for the action items
    action_nodes = []
    for item in action_items:
        node = ActionNode(item=item, workbench=workbench)
        action_nodes.append(node)

    # add the action nodes to the tree structure
    for node in action_nodes:
        parent_path = node.parent_path
        if parent_path not in node_map:
            msg = "the path '%s' does not point to a menu item"
            raise ValueError(msg % parent_path)
        path = node.path
        if path in node_map:
            msg = "an item already exist for path '%s'"
            raise ValueError(msg % path)
        parent = node_map[parent_path]
        parent.children.append(node)
        node_map[path] = node

    # generate the menus for the root nodes
    return root.assemble()
dataset/ETHPy150Open nucleic/enaml/enaml/workbench/ui/menu_helper.py/create_menus/operator `in` -> `<=`