Fix bad variable name
Wrap prefix_hierarchy iterator in a conditional
Conditionally return parsed history data

The parser throws an error about $final sometimes not exist. It should
*always* exist, but apparently does not, so we wrap it in a conditional.