Changed set to map, so we don't terminate a possibly promising path
because a state occurred in a greater depth.