Simplify code involving deque.popleft

popleft() returns the removed element.