Since parsing only goes in one direction, we can probably just store tag names as we find them and keep a counter variable that can be used to grab the previous one easily.