fixing bug in pruneElementTree