Iterating of some structure and removing elements thereby is always errorprone and should be avoided. But: In case of AA, I've got the feeling, that it might be safe: > foreach (k,v;ways) > if (v.empty) > ways.remove(k); Do you agree? Or is there a better way to achieve this?