def form_page_ranges(current_page, last_page):
    """Leave only the first 2, the last 2 pages, and selected page with 4 its neighbours.

    The method assumes that less than 10 pages shouldn't be separated.

    Example outputs:
      * if 6 is selected, 11 pages total:  [[1, 2], [4, 5, 6, 7, 8], [10, 11]]
      * if 4 is selected, 11 pages total:  [[1, 2, 3, 4, 5, 6], [10, 11]]
      * if 11 is selected, 11 pages total:  [[1, 2], [9, 10, 11]]
    """
    if last_page <= 10:
        return [list(range(1, last_page + 1))]

    leftmost_neighbour = current_page - 2
    rightmost_neighbour = current_page + 3

    displayed_ranges = []
    current_range = [1, 2]  # the first 2 pages

    if leftmost_neighbour > 3:  # apart from the first 2 pages
        displayed_ranges.append(current_range)
        current_range = []
        if rightmost_neighbour < last_page - 1:  # apart from the last 2 pages
            displayed_ranges.append(list(range(leftmost_neighbour, rightmost_neighbour)))
        else:  # merge with the last 2 pages
            current_range += list(range(leftmost_neighbour, last_page - 1))
    else:  # merge with the first 2 pages
        current_range += list(range(3, rightmost_neighbour))
        displayed_ranges.append(current_range)
        current_range = []

    current_range += [last_page - 1, last_page]  # the last 2 pages
    displayed_ranges.append(current_range)

    return displayed_ranges