public IEnumerable <NamedThing> ReachableNamedThings(GraphStatement fromStatement, params NamedThing[] ignoredNamedThings)
        {
            if (fromStatement == null)
            {
                throw new ArgumentNullException("fromStatement");
            }
            if (ignoredNamedThings == null)
            {
                throw new ArgumentNullException("ignoredNamedThings");
            }

            var ignoredNTs = new HashSet <NamedThing>(ignoredNamedThings.Where(nt => nt != null));

            var reachableNTs = new HashSet <NamedThing>(fromStatement.References);

            reachableNTs.RemoveWhere(ignoredNTs.Contains);

            var allReferences = statements.Where(s => s != fromStatement).Select(s => new HashSet <NamedThing>(s.References)).Where(r => r.Count > 0).ToList();

            for (int i = allReferences.Count - 1; i >= 0; i--)
            {
                var refs = allReferences[i];
                if (refs.Any(reachableNTs.Contains))
                {
                    refs.RemoveWhere(ignoredNTs.Contains);
                    reachableNTs.UnionWith(refs);
                    allReferences.RemoveAt(i);
                    i = allReferences.Count - 1;
                }
            }

            return(reachableNTs.Select(nt => nt));
        }
        public void Add(GraphStatement statement)
        {
            if (statement == null)
            {
                throw new ArgumentNullException("statement");
            }

            statements.Add(statement);
        }