'Retrieves the named destinations present in the document.
:return: a dictionary which maps names to
:class:`Destinations<PyPDF2.generic.Destination>`.
:rtype: dict'

def getNamedDestinations(self, tree=None, retval=None):

    if (retval == None):
        retval = {}
        catalog = self.trailer['/Root']
        if ('/Dests' in catalog):
            tree = catalog['/Dests']
        elif ('/Names' in catalog):
            names = catalog['/Names']
            if ('/Dests' in names):
                tree = names['/Dests']
    if (tree == None):
        return retval
    if ('/Kids' in tree):
        for kid in tree['/Kids']:
            self.getNamedDestinations(kid.getObject(), retval)
    if ('/Names' in tree):
        names = tree['/Names']
        for i in range(0, len(names), 2):
            key = names[i].getObject()
            val = names[(i + 1)].getObject()
            if (isinstance(val, DictionaryObject) and ('/D' in val)):
                val = val['/D']
            dest = self._buildDestination(key, val)
            if (dest != None):
                retval[key] = dest
    return retval
