checkbox list tree structure

I have menu array like…


$menuItems = ArrayHelper::map($menuItems, 'menu_id', 'menu_name');

and sub-menu array like…


$submenuItems = ArrayHelper::map($submenuItems, 'submenu_id', 'submenu_name');

now in the data base sub-menus are grouped under some menu…

in view form how can i form a tree structure with checkbox list like there will be menus checkboxlist

under which there would be corrosponding sub-menus checkbox list.