def get_boundaries(obj):
    """Return the boundaries_rect attribute of menu manager.

    obj (a menubar.widget.Menu instance)

    Checks the parent of obj, then the parent of its parent
    and so on until it reaches a parent which isn't of the
    same class of the child. A parent which isn't of the
    same class of the child is, by consequence, the
    MenuManager instance (because of how the relationship
    between the instances of those classes is designed).

    Once the MenuManager instance is found, the pygame.Rect
    instance in its boundaries_rect attribute is returned.
    """
    ### loop indefinitely until the breaking condition is
    ### met

    while True:

        ## retrieve the parent of the obj
        parent = obj.parent

        ## breaking condition: if the parent isn't of the
        ## same class of obj (its child), we can break of
        ## the loop
        if not isinstance(parent, obj.__class__):
            break

        ## otherwise we just consider the parent as the
        ## obj for the next iteration
        else:
            obj = parent

    ### once we break out of the while loop, we return the
    ### boundaries_rect attribute of the parent
    return parent.boundaries_rect
Return the boundaries_rect attribute of menu manager.

    obj (a menubar.widget.Menu instance)

    Checks the parent of obj, then the parent of its parent
    and so on until it reaches a parent which isn't of the
    same class of the child. A parent which isn't of the
    same class of the child is, by consequence, the
    MenuManager instance (because of how the relationship
    between the instances of those classes is designed).

    Once the MenuManager instance is found, the pygame.Rect
    instance in its boundaries_rect attribute is returned.
    
nodezator/menu/submenu/utils.py