public TaxonomyTree(ILog log, TaxonRepository repo, RelationService relationSrv, int rootId)
        {
            this.log         = log;
            this.rootId      = rootId;
            this.repo        = repo;
            this.relationSrv = relationSrv;
            rootEntity       = repo.Get(rootId);

            if (rootEntity == null)
            {
                if (rootId == 1)
                {
                    rootEntity = new TaxonEntity()
                    {
                        Name        = "Root",
                        Description = "Root node - parent of all taxon entries"
                    };
                    repo.Save(rootEntity);
                }
                else
                {
                    throw new Exception("Root node is not found");
                }
            }
            rootNode = new TaxonomyNode(this, rootEntity);
        }
        internal TaxonomyNode AddChildTo(TaxonomyNode taxon, string name, string description)
        {
            if (taxon.IsDetached)
            {
                throw new Exception(String.Format("Taxon '{0}' is detached", taxon.Name));
            }
            if (taxon.Children.Any(x => x.Name == name))
            {
                throw new DataLayerException("Duplicate taxon name in node");
            }
            var entity = new TaxonEntity()
            {
                Name        = name,
                Description = description
            };

            repo.Save(entity);
            relationSrv.AddRelation(taxon.entity, entity, RelationDirection.Forward, rootNode);
            var newNode = new TaxonomyNode(this, entity)
            {
                parent = taxon
            };

            taxon.children.Add(newNode);
            return(newNode);
        }