Iran, a longtime backer of Gaza's rulers Hamas, finds itself in a quandary as it tries to manage the spiralling crisis.