def METHOD_NAME(indices, prev, T):
    for pos,i in enumerate(indices):
        U = prev * T
        mu = U * phi[i]
        mu = mu.stack(matrix.diagonal([B[i]]).dense_matrix())
        row_syzygy = matrix(S, syz(mu.transpose())).matrix_from_columns(range(r))
        Y = less_generators(row_syzygy)
        if not Y.is_square():
            continue
        if len(indices) == 1:
            return [prev, Y]
        I = list(indices)
        I.pop(pos)
        ret = METHOD_NAME(I, Y, U)
        if ret is not None:
            return [prev] + ret
    return None