We should always check whether startTag is null or not here since we can't be sure that tagStack.pop() always succeeds in returning one.