function* traverse_menu(menu_items, menu_element) {
	// Traverse menu data and elements in tandem, yielding pairs of menu item specifications and elements.
	// This approach handles identically named menu items in separate menus,
	// as is the case with "File > Manage Storage" and "Edit > History", both present in the Extras menu,
	// but also in the other menus for discoverability.
	// However, it doesn't handle identically named menu items in the same menu,
	// as it still matches up items within the menu using aria-label.

	// Menu structure:
	// - Menu popups are not descendants of the menu bar or other menu popups; they are always direct children of the body.
	// - Menu items that open submenus have "aria-controls" pointing to the ID of the submenu.
	// - (Menu popups also have "data-semantic-parent" pointing to the ID of the menu item that opens them.)
	// - `submenu` is an array, but the top level (menu bar) is represented as an object, which is a bit awkward.
	//   However, this function doesn't deal with the top level.

	const menu_item_elements = /** @type {HTMLElement[]} */([...menu_element.querySelectorAll(".menu-item")]);
	for (const menu_item of menu_items) {
		if (typeof menu_item !== "object" || !("label" in menu_item)) {
			continue;
		}
		const aria_label = AccessKeys.toText(menu_item.label);
		const menu_item_element = menu_item_elements.filter((el) =>
			el.getAttribute("aria-label") === aria_label
		)[0];
		if (!menu_item_element) {
			console.warn("Couldn't find menu item", menu_item, "with aria-label", aria_label);
			continue;
		}
		yield [menu_item, menu_item_element];
		if (menu_item.submenu) {
			yield* traverse_menu(menu_item.submenu, menu_document.getElementById(menu_item_element.getAttribute("aria-controls")));
		}
		// if (menu_item.radioItems) {
		// 	yield* traverse_menu(menu_item.radioItems, menu_element);
		// }
	}
}
@param {OSGUIMenuFragment[]} menu_items
@param {HTMLElement} menu_element
@yields {[OSGUIMenuItem, HTMLElement]}
@returns {Generator<[OSGUIMenuItem, HTMLElement], void, void>}