LIFO: Rpop jobs

I run across a case where I wanted to process jobs in LIFO order.
There is quite some duplicate code in lpop and rpop but I wanted to be as non-invasive as possible.