diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index bf3346b7c0faf53fc94965f4ead99478ab504f73..d14042528f2be961e0798b29caea323a5341c510 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -4423,6 +4423,7 @@ PUGI__NS_BEGIN
 
 		while (sit && sit != sn)
 		{
+			// when a tree is copied into one of the descendants, we need to skip that subtree to avoid an infinite loop
 			if (sit != dn)
 			{
 				xml_node_struct* copy = append_new_node(dit, alloc, PUGI__NODETYPE(sit));