private static XDocument MergeActiveProfile(XDocument defaultDocument, XElement activeProfileElement)
        {
            XElement root = defaultDocument.Root;

            foreach (XElement current in activeProfileElement.Elements())
            {
                XElement xElement = root.Descendants(current.Name).FirstOrDefault <XElement>();
                if (xElement == null)
                {
                    root.Add(current);
                }
                else
                {
                    xElement.Remove();
                    root.Add(AppInsightsConfigReader.MergeElements(xElement, current));
                }
            }
            return(defaultDocument);
        }
        private static XElement MergeElements(XElement existingElement, XElement activeElement)
        {
            XElement xElement = new XElement(activeElement);

            foreach (XElement current in existingElement.Elements())
            {
                XElement xElement2 = xElement.Descendants(current.Name).FirstOrDefault <XElement>();
                if (xElement2 == null)
                {
                    xElement.Add(current);
                }
                else
                {
                    if (current.HasElements)
                    {
                        xElement2.Remove();
                        xElement.Add(AppInsightsConfigReader.MergeElements(current, xElement2));
                    }
                }
            }
            return(xElement);
        }