Fixes #13779. Remove nodes in document order

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>