public Bookmark AddBookmark(Page page, Title title) { Bookmark bm = this; while (bm.parent != null) { bm = bm.GetParent(); } String key = bm.Next(); Bookmark bookmark = new Bookmark( page, title.textLine.GetDestinationY(), key, Regex.Replace(title.textLine.text, @"\s+", " ")); bookmark.parent = this; bookmark.dest = page.AddDestination(key, title.textLine.GetDestinationY()); if (children == null) { children = new List <Bookmark>(); } else { bookmark.prev = children[children.Count - 1]; children[children.Count - 1].next = bookmark; } children.Add(bookmark); return(bookmark); }