Refactor search_upwards_in_buffer.

Extract new method iter_buffer_lines_upwards and rename search to
search_buffer_lines_upwards.