Debug _get_previous_or_next