'Add a bookmark to this PDF file.
:param str title: Title to use for this bookmark.
:param int pagenum: Page number this bookmark will point to.
:param parent: A reference to a parent bookmark to create nested
bookmarks.'

def addBookmark(self, title, pagenum, parent=None):

    if (parent == None):
        iloc = [(len(self.bookmarks) - 1)]
    elif isinstance(parent, list):
        iloc = parent
    else:
        iloc = self.findBookmark(parent)
    dest = Bookmark(TextStringObject(title), NumberObject(pagenum), NameObject('/FitH'), NumberObject(826))
    if (parent == None):
        self.bookmarks.append(dest)
    else:
        bmparent = self.bookmarks
        for i in iloc[:(-1)]:
            bmparent = bmparent[i]
        npos = (iloc[(-1)] + 1)
        if ((npos < len(bmparent)) and isinstance(bmparent[npos], list)):
            bmparent[npos].append(dest)
        else:
            bmparent.insert(npos, [dest])
    return dest
