While you managed to shave off some queries using `values_list`, you're currently making a Device.objects.get() query for each `pop()` on the stack. Those objects are on the stack already. Is it necessary to query for them again?