def merge_vertical_lines(lines, tol=TOLERANCE):
if len(lines) == <NUM_LIT:0>:<EOL><INDENT>return []<EOL><DEDENT>merged_lines = [lines[<NUM_LIT:0>]]<EOL>for line in lines[<NUM_LIT:1>:]:<EOL><INDENT>last_line = merged_lines[-<NUM_LIT:1>]<EOL>if line[<NUM_LIT:1>] == last_line[<NUM_LIT:1>]:  <EOL><INDENT>if line[<NUM_LIT:0>] <= last_line[<NUM_LIT:2>] + tol:  <EOL><INDENT>y0, x0, y1, x1 = merged_lines[-<NUM_LIT:1>]<EOL>merged_lines[-<NUM_LIT:1>] = (y0, x0, line[<NUM_LIT:2>], x1)<EOL><DEDENT>else:<EOL><INDENT>merged_lines.append(<EOL>line<EOL>)  <EOL><DEDENT><DEDENT>else:<EOL><INDENT>merged_lines.append(line)<EOL><DEDENT><DEDENT>return merged_lines<EOL>
This function merges lines segment when they are vertically aligned
:param lines: list of lines coordinates (top, left, bottom, right)
:return: list of merged lines coordinates