public static string GetFormattedBreadCrumb(this BranchGroup category,
            IBranchService branchService,
            string separator = ">>")
        {
            if (category == null)
                throw new ArgumentNullException("category");

            string result = string.Empty;

            //used to prevent circular references
            var alreadyProcessedBranchGroupIds = new List<int>() { };

            while (category != null &&  //not null
                !category.Deleted &&  //not deleted
                !alreadyProcessedBranchGroupIds.Contains(category.Id)) //prevent circular references
            {
                if (String.IsNullOrEmpty(result))
                {
                    result = category.Name;
                }
                else
                {
                    result = string.Format("{0} {1} {2}", category.Name, separator, result);
                }

                alreadyProcessedBranchGroupIds.Add(category.Id);

                category = branchService.GetBranchGroupById(category.ParentGroupId);

            }
            return result;
        }
        public static IList<BranchGroup> GetBranchGroupBreadCrumb(this BranchGroup branchGroup,
            IBranchService branchService,
            bool showHidden = false)
        {
            if (branchGroup == null)
                throw new ArgumentNullException("branchGroup");

            var result = new List<BranchGroup>();

            //used to prevent circular references
            var alreadyProcessedBranchGroupIds = new List<int>() { };

            while (branchGroup != null && //not null
                !branchGroup.Deleted && //not deleted
                !alreadyProcessedBranchGroupIds.Contains(branchGroup.Id)) //prevent circular references
            {
                result.Add(branchGroup);

                alreadyProcessedBranchGroupIds.Add(branchGroup.Id);

                branchGroup = branchService.GetBranchGroupById(branchGroup.ParentGroupId);
            }
            result.Reverse();
            return result;
        }