def insert(self, i, x):
if i == len(self):  <EOL><INDENT>self.append(x)<EOL><DEDENT>elif len(self.matches) > i:<EOL><INDENT>insert_index = self.matches[i].getparent().index(self.matches[i])<EOL>_create_xml_node(self.xast, self.node, self.context, insert_index)<EOL>self[i] = x<EOL><DEDENT>else:<EOL><INDENT>raise IndexError("<STR_LIT>"% (x, i, len(self)))<EOL><DEDENT>
Insert an item (x) at a given position (i).