Ah! I figured it out. I forgot that the tree is treated like a list. The solution was to replace the <random> element with the first <item> child, then use Python's insert(i,x) function to insert elements after the first one. lxml rocks!