Get wordpress menu items in multidimensional array

It is very wired when we need to implement mega menu in a wordpress with a walker or any other wordpress hook or wordpress function.We need to build  own structure for menu ,we need to get all the menus object with their hierarchy for putting our menu in the custom html.So for getting all wordpress menus array with in a certain location use the following function.

call the function with a location ,eg  $menus_items = menu_hirechy_creater(‘header’);

where header is the menu location.