Make users of get_literal_value more resilliant to failure

I'm wondering whether we should give up on passing the traverser around
on the stack and refer to the reference that's on the heap instead.