/// <summary>
 /// Removes the target namespace and all parent namespaces that are empty after the removal.
 /// </summary>
 static void RemoveTestNamespace(TestCollection collection, string parentNamespace, string @namespace)
 {
     if (parentNamespace == @namespace)
     {
         return;
     }
     foreach (var node in collection.OfType <TestNamespace>())
     {
         if (@namespace == node.NamespaceName)
         {
             collection.Remove(node);
             return;
         }
         if (@namespace.StartsWith(node.NamespaceName + ".", StringComparison.Ordinal))
         {
             RemoveTestNamespace(node.NestedTests, node.NamespaceName, @namespace);
             if (node.NestedTests.Count == 0)
             {
                 collection.Remove(node);
             }
             return;
         }
     }
 }
        void RemoveTestClass(TopLevelTypeName fullName, ITest test)
        {
            topLevelTestClasses.Remove(fullName);
            TestCollection testNamespace = FindNamespace(NestedTestCollection, project.RootNamespace, fullName.Namespace);

            if (testNamespace != null)
            {
                testNamespace.Remove(test);
                if (testNamespace.Count == 0)
                {
                    // Remove the namespace
                    RemoveTestNamespace(NestedTestCollection, project.RootNamespace, fullName.Namespace);
                }
            }
            OnTestClassRemoved(test);
        }