def add_tag_before(tag_name, tag_text, parent_tag, before_tag_name):
new_tag = Element(tag_name)<EOL>new_tag.text = tag_text<EOL>if get_first_element_index(parent_tag, before_tag_name):<EOL><INDENT>parent_tag.insert( get_first_element_index(parent_tag, before_tag_name) - <NUM_LIT:1>, new_tag)<EOL><DEDENT>return parent_tag<EOL>
Helper function to refactor the adding of new tags
especially for when converting text to role tags