Clear the root element every iteration

Without this the root tree gets a bunch of cleared elements and we'll run out of memory eventually.

See http://stackoverflow.com/a/326541/73004