Reading out all operators in a header's menu How is it possible to read out the menus of a header and the operators in the menus with Python?

Background:
I have an external hardware with some configurable keys, and I want to trigger the operators in Blender's menus with the keys. In the hardware's GUI is a dialog to assign functions to the keys. In this dialog is a list of available functions, and I try to fill this list with all of Blender's menu items. If possible the list should show up in the same hierarchical structure (menus and submenus) as in Blender and reflecting the actual state Blender is in.
There's no straight-forward way to retrieve the contents of menus or other layout types.

If possible, create shortcuts in the User Preferences, but that might not be possible with external hardware keys. Or if that's sufficient for you, Right-click > Edit Source to see the layout code (mostly python-scripted).

It might be feasible to extract layout information somehow by hacking deep into the Blender internals with Python, see this to get an idea:

http://wiki.blender.org/index.php?title=Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Interface&amp;oldid=226944#Overriding_Interface_Elements