Islamic State may appear to be on the ropes in the Middle East, but its recent losses should be viewed in the context of a longer struggle.