internal static void FlattenDomain(IProgress progress, bool writeVerbose,
                                           SortedDictionary <string, XElement> highLevelData,
                                           SortedDictionary <string, XElement> sortedData,
                                           string rootDir)
        {
            var linguisticsBaseDir = Path.Combine(rootDir, SharedConstants.Linguistics);

            if (!Directory.Exists(linguisticsBaseDir))
            {
                return;
            }

            // Do in reverse order from nesting.
            if (writeVerbose)
            {
                progress.WriteVerbose("Collecting the linguistics data....");
                progress.WriteVerbose("Collecting the phonology data....");
            }
            else
            {
                progress.WriteMessage("Collecting the linguistics data....");
                progress.WriteMessage("Collecting the phonology data....");
            }
            PhonologyBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);

            if (writeVerbose)
            {
                progress.WriteVerbose("Collecting the discourse data....");
            }
            else
            {
                progress.WriteMessage("Collecting the discourse data....");
            }
            DiscourseAnalysisBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);

            if (writeVerbose)
            {
                progress.WriteVerbose("Collecting the wordform and punctuation data....");
            }
            else
            {
                progress.WriteMessage("Collecting the wordform and punctuation data....");
            }
            WordformInventoryBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);

            if (writeVerbose)
            {
                progress.WriteVerbose("Collecting the text corpus data....");
            }
            else
            {
                progress.WriteMessage("Collecting the text corpus data....");
            }
            TextCorpusBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);

            // MorphologyAndSyntaxBoundedContextService and ReversalBoundedContextService, both *must* have LexiconBoundedContextService done before them,
            // since they re-add stuff to LexDb that they removed
            if (writeVerbose)
            {
                progress.WriteVerbose("Collecting the lexical data....");
            }
            else
            {
                progress.WriteMessage("Collecting the lexical data....");
            }
            LexiconBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);

            if (writeVerbose)
            {
                progress.WriteVerbose("Collecting the morphology and syntax data....");
            }
            else
            {
                progress.WriteMessage("Collecting the morphology and syntax data....");
            }
            MorphologyAndSyntaxBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);

            if (writeVerbose)
            {
                progress.WriteVerbose("Collecting the reversal data....");
            }
            else
            {
                progress.WriteMessage("Collecting the reversal data....");
            }
            ReversalBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);
        }