/// <summary>
        /// Loads the specified settings file into this settings document by creating the settings node tree based on the file's
        /// tab structure. Any line that contains only whitespace or only a comment will not become a <see cref="SettingsNode"/>
        /// but will be retained when the file is saved.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <exception cref="FileNotFoundException">The file specified in <c>filename</c> was not found.</exception>
        private void LoadFromStream(StreamReader stream)
        {
            List <string> lineComments = new List <string>();

            Nodes.Clear();
            SettingsNode prevNode = this;

            string line;

            while ((line = stream.ReadLine()) != null)
            {
                //Check the line for a valid node name
                if (String.IsNullOrWhiteSpace(line) || line.TrimStart().StartsWith(";"))
                {
                    lineComments.Add(line);
                    continue;
                }

                // Find the node's level
                int level = 0;
                while (line.ElementAt(level) == '\t')
                {
                    level++;
                }

                // Create a new settings node
                SettingsNode currentNode = CreateNode(line);

                // Attach preceding file comments to the current node
                if (lineComments.Count > 0)
                {
                    for (int i = 0; i < lineComments.Count; i++)
                    {
                        currentNode.AddPrecedingComment(lineComments[i]);
                    }

                    lineComments.Clear();
                }

                // Add the current node at the proper level
                if (level == 0)
                {
                    _nodes.Add(currentNode);
                }
                else if (level == prevNode.Level)
                {
                    prevNode.Parent.Nodes.Add(currentNode);
                }
                else if (level > prevNode.Level)
                {
                    prevNode.Nodes.Add(currentNode);
                }
                else // level < prevNode.Level
                {
                    while (level <= prevNode.Level)
                    {
                        prevNode = prevNode.Parent;
                    }

                    prevNode.Nodes.Add(currentNode);
                }

                // Update the previous node
                prevNode = currentNode;
            }

            if (lineComments.Count > 0)
            {
                _trailingComments = lineComments;
            }
        }