You could first check if $items[$count + 1] exists. Like
if( //check first if $items[$count + 1] exists, else it breaks here isset($items[ $count + 1 ] ) //now you know $item[$count + 1] exists, so you can continue && ( $items[$count + 1]->menu_item_parent != $parent_id && $submenu && $items[ $count + 1 ]->menu_item_parent != $item->ID ) ){ //something }