def fix_scrolling(self):
        """Eliminate excessive scrolling.

        Closes gap between first child/first arrow or
        last child/last_arrow if it exists. Such gap is
        sometimes formed when scrolling the first or last
        child inwards the scroll area, since their width
        isn't a multiple of the scrolling speed.
        """
        ### retrieve rects of first and last children

        first_rect = self.children[0].rect
        last_rect = self.children[-1].rect

        ### before starting to check if there's an gap we
        ### must check if at least one of the children
        ### is completely inside the scroll area, because
        ### since there can't be any gap if the neither
        ### children is inside such area there would be no
        ### point in checking anyway

        ## check whether each child is completely inside the
        ## scroll area

        first_inside = self.scroll_area.contains(first_rect)
        last_inside = self.scroll_area.contains(last_rect)

        ## if neither the first nor the last rect are
        ## completely inside the scroll area, cancel the
        ## execution of the rest of the method by returning
        ## earlier
        if not first_inside and not last_inside:
            return

        ### now determine which of the children is the one
        ### inside the the scroll area (they can't be both
        ### completely inside, otherwise there would be no
        ### need to make the menu scrollable in the first
        ### place) and whether there's a gap and fix it if
        ### it is the case

        ## if the first_rect is inside the scroll area
        ## and its top isn't aligned with the up arrow
        ## bottom it means there's a gap, so align them by
        ## moving the children by the difference between
        ## them

        if first_inside and first_rect.top != self.up_arrow.rect.bottom:

            # calculate the difference
            y_offset = self.up_arrow.rect.bottom - first_rect.top

            # move children
            self.children.rect.move_ip(0, y_offset)

        ## otherwise if it is the last_rect which is inside
        ## the scroll area and its bottom isn't aligned with
        ## the down arrow top, then there's a gap, so align
        ## them by moving the children by the difference
        ## between them

        elif last_inside and last_rect.bottom != self.down_arrow.rect.top:

            # calculate the difference
            y_offset = self.down_arrow.rect.top - last_rect.bottom

            # move children
            self.children.rect.move_ip(0, y_offset)
Eliminate excessive scrolling.

        Closes gap between first child/first arrow or
        last child/last_arrow if it exists. Such gap is
        sometimes formed when scrolling the first or last
        child inwards the scroll area, since their width
        isn't a multiple of the scrolling speed.
        
nodezator/menu/submenu/scroll.py