def tag_limit_sibling_ordinal(tag, stop_tag_name):
tag_count = <NUM_LIT:1><EOL>for prev_tag in tag.previous_elements:<EOL><INDENT>if prev_tag.name == tag.name:<EOL><INDENT>tag_count += <NUM_LIT:1><EOL><DEDENT>if prev_tag.name == stop_tag_name:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return tag_count<EOL>
Count previous tags of the same name until it
reaches a tag name of type stop_tag, then stop counting