Its relatively easy.. The Device class has a child called 'chains' which you can get or observe. As such that is your key to getting all the chain id's of a rack. Once you have the id's you can iterate over 'm (go over them one by one) using the 'zl' object (use the 'iter 2' option).
You can then get the Name property and you're done.
You mention "M4L menu" but there really is no such thing; M4L provides several ways of menus. There is a problem though, unfortunately the "live.menu" object isn't the easiest when it comes to dynamic changes.
If you're not looking for something which can be controlled by a control surface (such as the APC40) then I'd recommend using the 'umenu' object instead. This makes it much easier to control the menu contents.
As said; the downside to this is although its perfectly usable in Live you can't map this critter in any way nor will you be able to control it using external devices such as the apc40.