Generator only traverse if possible