/// <summary>
        /// Dodaje novi "list" -- krajnji element u strukturi koji obicno nosi i vrednost -- pravi strukturu koja je neophodna da bi ova grana profukncionisala
        /// </summary>
        /// <param name="leafNameOfPath">Putanja se prosledjuje u sourcePath</param>
        /// <param name="value"></param>
        /// <param name="report"></param>
        /// <returns></returns>
        public imbTreeNodeLeaf AddNewLeaf(String leafNameOfPath, Object value, ITextRender report = null,
                                          String __sourceContent = "")
        {
            String __sourcePath = leafNameOfPath;

            pathSegments psq        = new pathSegments();
            String       branchName = "";

            psq.deployPath(leafNameOfPath, pathResolveFlag.autorenameCollectionIndexer);
            String leafName = psq.lastSegment.needle; //leafNameOfPath;

            if (psq.Count > 1)
            {
                psq.Remove(psq.lastSegment);
                branchName = psq.ToString();
            }

            imbTreeNodeBranch head = this;

            if (!String.IsNullOrEmpty(branchName))
            {
                head = AddNewBranch(branchName, report);
            }

            if (head == null)
            {
                head = this;
            }

            if (report != null)
            {
                //report.AppendLine("Adding new leaf: " + leafName + "  inside: " + head.path);
            }

            imbTreeNodeLeaf newLeaf = new imbTreeNodeLeaf(leafName, value);

            newLeaf.sourcePath    = __sourcePath;
            newLeaf.sourceContent = __sourceContent;
            head.Add(newLeaf);

            return(newLeaf);
        }
        /// <summary>
        /// Pravi novu granu - ili strukturu pod grana -- ako je prosledjena putanja umesto obicnog imena
        /// </summary>
        /// <param name="branchName"></param>
        /// <returns></returns>
        public imbTreeNodeBranch AddNewBranch(String branchNameOrPath, ITextRender report = null)
        {
            sourcePath = branchNameOrPath;
            pathResolverResult query = this.resolvePath(branchNameOrPath, pathResolveFlag.autorenameCollectionIndexer);
            imbTreeNodeBranch  head  = null;

            switch (query.type)
            {
            case pathResolverResultType.foundOne:
            case pathResolverResultType.foundMany:
                //head = query.nodeFound. as imbTreeNodeBranch;
                head = query.nodeFound.imbFirstSafe() as imbTreeNodeBranch;

                /*
                 *                  Exception ex = new aceGeneralException("Branch is already found at: " + branchNameOrPath);
                 *
                 *                   var isb = new imbStringBuilder(0);
                 *                   isb.AppendLine("Can't add new branch on place where the one already exists error");
                 *                   isb.AppendPair("Target is: ", this.toStringSafe());
                 *                   devNoteManager.note(this, ex, isb.ToString(), "Can't add new branch on place where the one already exists", devNoteType.unknown);
                 */
                break;

            default:
            case pathResolverResultType.nothingFound:

            case pathResolverResultType.folderFoundButItemMissing:
            case pathResolverResultType.folderFoundButFoldersMissing:
                imbTreeNode nd = query.nodeFound.imbFirstSafe() as imbTreeNode;
                if (nd is imbTreeNodeLeaf)
                {
                    head = nd.parent;
                    imbTreeNodeBranch newBranch = new imbTreeNodeBranch(nd.name);
                    newBranch.learnFrom(nd);

                    head.Remove(nd.keyHash);
                    head.Add(newBranch);
                    head = newBranch;

                    if (report != null)
                    {
                        //report.AppendPair("replacing existing Leaf node with branch one", head.name);
                    }
                }
                else
                {
                    head = nd as imbTreeNodeBranch;
                }

                if (head == null)
                {
                    head = this;
                }
                foreach (pathSegment ps in query.missing)
                {
                    imbTreeNodeBranch newBranch = new imbTreeNodeBranch(ps.needle);
                    head.Add(newBranch);

                    if (report != null)
                    {
                        //report.AppendPair("Add new node to [" + head.path + "] : ", newBranch.name);
                    }
                    head = newBranch;
                }
                break;
            }

            return(head);
        }