The place that uses this flag does ensure its dealing with an `li` element now, so your first point shouldn't be a problem.

You are correct that it is possible that there would be two or more closing `li` tags that need removal (although that would require a pretty horribly broken list to achieve), so I switched this flag to a counter that can be incremented and decremented to keep track of how many extra closing `li` tags the parser should expect.