### Godot version

4.0.2

### System information

Windows 11

### Issue description

Changing node type from PopupMenu to ItemList causes Godot to crash

### Steps to reproduce

Change node type from PopupMenu to ItemList

### Minimal reproduction project

n/a
ERR_FAIL_COND(p_event.is_null());
	if (!items.is_empty()) {
		if (p_event->is_action("ui_down", true) && p_event->is_pressed()) {
			int search_from = mouse_over + 1;
			if (search_from >= items.size()) {
				search_from = 0;
			}
			bool match_found = false;
			for (int i = search_from; i < items.size(); i++) {
				if (!items[i].separator && !items[i].disabled) {
					mouse_over = i;
					emit_signal(SNAME("id_focused"), i);
					scroll_to_item(i);
					control->queue_redraw();
					set_input_as_handled();
					match_found = true;
					break;
				}
			}
			if (!match_found) {
				
				for (int i = 0; i < search_from; i++) {
					if (!items[i].separator && !items[i].disabled) {
						mouse_over = i;
						emit_signal(SNAME("id_focused"), i);
						scroll_to_item(i);
						control->queue_redraw();
						set_input_as_handled();
						break;
					}