depth
argument, available in functions attached to wp_nav_menu_objects
hook, refers to the max depth of rendered menu (how many menu levels will be visible on site).
To change only first-level elements, you can check in the loop if the menu item has a parent.
function change_menu($items) {
if( !is_front_page() ) {
foreach($items as $item) {
if ( $item->menu_item_parent != 0 )
continue;
$item->url = "https://wordpress.stackexchange.com/" . $item->url;
}
}
return $items;
}
add_filter('wp_nav_menu_objects', 'change_menu');