import typing

from apps.authorization.models import Role


def get_all_role_child(role: Role = None) -> typing.Any:
    """
    get all child of an role
    """
    descendants = []
    children = role.child.all()
    for child in children:
        descendants.append(child)
        descendants.extend(get_all_role_child(child))
    return descendants
