def METHOD_NAME(list_a, mask_l, level, flags, idx=0):
    mask_out, ind_true, ind_false, result_t, result_f = [], [], [], [], []
    if level > 1:
        if isinstance(list_a, (list, tuple, np.ndarray)):
            result = [mask_out, ind_true, ind_false, result_t, result_f]
            for idx, sub_list in enumerate(list_a):
                for i, res in enumerate(METHOD_NAME(sub_list, mask_l, level - 1, flags, idx)):
                    result[i].append(res)
    else:
        indx = min(len(mask_l)-1, idx)
        mask = mask_l[indx]
        if type(list_a) == np.ndarray:
            return mask_array(list_a, mask, flags)
        else:
            return mask_list(list_a, mask, flags)
    return mask_out, ind_true, ind_false, result_t, result_f