diff --git a/MagickCore/xml-tree.c b/MagickCore/xml-tree.c
index 69a3f98..3bba500 100644
--- a/MagickCore/xml-tree.c
+++ b/MagickCore/xml-tree.c
@@ -474,12 +474,11 @@
   assert((xml_info->signature == MagickSignature) ||
          (((XMLTreeRoot *) xml_info)->signature == MagickSignature));
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
-  if (xml_info->parent == (XMLTreeInfo *) NULL)
+  if (xml_info->parent != (XMLTreeInfo *) NULL)
     return;
   /*
     Free root tag allocations.
   */
-  return;
   root=(XMLTreeRoot *) xml_info;
   for (i=NumberPredefinedEntities; root->entities[i] != (char *) NULL; i+=2)
     root->entities[i+1]=DestroyString(root->entities[i+1]);