fix bug in solver_get_unneeded that could lead to an endless loop