Added support for nested sub-menu. fixes #1210

Removed the loop from menu() and replaced it will a call to menuBuilder().
Added menuBuilder() function containing a modified version of the loop from menu().