global $menuItems;
global $parentMenuIds;
//create an array of parent_menu_ids to search through and find out if the current items have an children
foreach($menu_items as $parentId)
{
$parentMenuIds[] = $parentId->parent_menu_id;
}
//assign the menu items to the global array to use in the function
$menuItems = $menu_items;