Fix YAML parser not tracking sequence index per tree level.

Also, switch to using the back of the deque, which is more efficient.