Added replaceParent to support extending multiple documents