public LevelMetadata FindLastLink()
        {
            LevelMetadata lastLink = this;
            LevelMetadata nextLink = this;

            while (nextLink != null)
            {
                lastLink = nextLink;
                nextLink = nextLink.NextLink();
            }

            return(lastLink);
        }
        //works on any link in the chain
        public int CalculateTotalLinkLength()
        {
            LevelMetadata firstLink = FindFirstLink();

            int linkLength = 1;

            while (null != firstLink && firstLink.LinkedToLevel != null)
            {
                firstLink = firstLink.NextLink();
                linkLength++;
            }

            return(linkLength);
        }
        public bool FindBrokenLink(ref LevelMetadata brokenLevel, ref bool forwardLink)
        {
            //initialize the out params - assume no broken link
            brokenLevel = null;
            forwardLink = false;

            //First, walk backwards to the first link
            LevelMetadata currentLink  = this;
            LevelMetadata previousLink = null;
            LevelMetadata nextLink     = null;

            while (currentLink.LinkedFromLevel != null)
            {
                //check to make sure the xml exists
                previousLink = currentLink.PreviousLink();

                if (null == previousLink)
                {
                    brokenLevel = currentLink;
                    forwardLink = false; //broke walking backwards

                    return(true);
                }
                currentLink = previousLink;
            }

            //first link now points to the beginning, walk forward to the end, ensuring we
            while (currentLink.LinkedToLevel != null)
            {
                //check to make sure the xml exists
                nextLink = currentLink.NextLink();

                if (null == nextLink)
                {
                    brokenLevel = currentLink;
                    forwardLink = false; //broke walking backwards

                    return(true);
                }
                currentLink = nextLink;
            }

            //if we made it this far, all of the links worked out
            return(false);
        }