def _schultz_get_closest_extrema(contour):
	"""
	Part of Step 11.
	Returns the closest repeating extrema to the start and end of the contour.

	From Ex15B:
	>>> contour = [
	...		[1, {1, -1}],
	... 	[3, {1}],
	... 	[0, {-1}],
	... 	[3, {1}],
	... 	[0, {-1}],
	... 	[3, {1}],
	... 	[0, {-1}],
	... 	[3, {1}],
	... 	[2, {1, -1}]
	... ]
	>>> maxima = [(1, [3, {1}]), (3, [3, {1}]), (5, [3, {1}]), (7, [3, {1}])]
	>>> minima = [(2, [0, {-1}]), (4, [0, {-1}]), (6, [0, {-1}])]
	>>> (c_start, c_end) = _schultz_get_closest_extrema(contour)
	>>> c_start
	('max', (1, [3, {1}]))
	>>> c_end
	('max', (7, [3, {1}]))
	"""
	# Find the closest elements. Unflag (and store) all repetions that are not those from above.
	closest_start_extrema = next((i + 1, x) for (i, x) in enumerate(contour[1:-1]) if 1 in x[1] or -1 in x[1])  # noqa
	closest_end_extrema = next((len(contour) - i - 2, x) for (i, x) in enumerate(contour[1:-1][::-1]) if 1 in x[1] or -1 in x[1])  # noqa

	if -1 in closest_start_extrema[1][1]:
		closest_start = ("min", closest_start_extrema)
	else:
		closest_start = ("max", closest_start_extrema)

	if -1 in closest_end_extrema[1][1]:
		closest_end = ("min", closest_end_extrema)
	else:
		closest_end = ("max", closest_end_extrema)

	return (closest_start, closest_end)