function minNorm = func_dperm_Q_aux(Q1, Q2, tau, current_element, remaining_indices, k)
% Recursive search for the best permutation of the states.

if (current_element == k+1)
    minNorm = norm(Q1(tau,tau) - Q2, 'fro');
else
    tau(current_element) = remaining_indices(1);
    minNorm = func_dperm_Q_aux(Q1, Q2, tau, current_element+1, ...
       	remaining_indices(2:end), k);
    for i=remaining_indices(2:end)
        tau(current_element) = i;
        minNorm = min(minNorm, ...
            func_dperm_Q_aux(Q1, Q2, tau, current_element+1, ...
                remaining_indices(find(remaining_indices~=i)), k));
    end
end
