def get_root_liveaction(liveaction_db):
    """Recursively ascends until the root liveaction is found

    Useful for finding an original parent workflow. Pass in any LiveActionDB instance,
    and this function will eventually return the top-most liveaction, even if the two
    are one and the same.

    :param liveaction_db: The LiveActionDB instance for which to find the root parent.
    :rtype: LiveActionDB
    """

    parent_liveaction_db = get_parent_liveaction(liveaction_db)

    return (
        get_root_liveaction(parent_liveaction_db)
        if parent_liveaction_db
        else liveaction_db
    )
Recursively ascends until the root liveaction is found

    Useful for finding an original parent workflow. Pass in any LiveActionDB instance,
    and this function will eventually return the top-most liveaction, even if the two
    are one and the same.

    :param liveaction_db: The LiveActionDB instance for which to find the root parent.
    :rtype: LiveActionDB
    
st2common/st2common/services/action.py