'Convert ``defaultdict`` to common ``dict`` representation.
:param: A defaultdict containing strings mapped to nested defaultdicts.
This is the structure of the trie. (Default is None)
:type: defaultdict(str -> defaultdict)
:return: Even though ``defaultdict`` is a subclass of ``dict`` and thus
can be converted to a simple ``dict`` using ``dict()``, in our case
it\'s a nested ``defaultdict``, so here\'s a quick trick to provide to
us the ``dict`` representation of the ``Trie`` without
``defaultdict(<class \'nltk.collections.Trie\'>, ...``
:rtype: dict(str -> dict(bool -> None))
Note: there can be an arbitrarily deeply nested
``dict(str -> dict(str -> dict(..))``, but the last
level will have ``dict(str -> dict(bool -> None))``
:Example:
>>> from nltk.collections import Trie
>>> trie = Trie(["abc", "def"])
>>> expected = {\'a\': {\'b\': {\'c\': {True: None}}}, \'d\': {\'e\': {\'f\': {True: None}}}}
>>> trie.as_dict() == expected
True'

def as_dict(self, d=None):

    def _default_to_regular(d):
        '\n                                                Source:    http://stackoverflow.com/a/26496899/4760801\n\n                                                :param    d:    Nested    ``defaultdict``    to    convert    to    regular    ``dict``\n                                                :type    d:    defaultdict(str    ->    defaultdict(...))\n                                                :return:    A    dict    representation    of    the    defaultdict\n                                                :rtype:    dict(str    ->    dict(str    ->    ...))\n\n                                                :Example:\n\n                                                >>>    from    collections    import    defaultdict\n                                                >>>    d    =    defaultdict(defaultdict)\n                                                >>>    d["one"]["two"]    =    "three"\n                                                >>>    d\n                                                defaultdict(<type    \'collections.defaultdict\'>,    {\'one\':    defaultdict(None,    {\'two\':    \'three\'})})\n                                                >>>    _default_to_regular(d)\n                                                {\'one\':    {\'two\':    \'three\'}}\n\n                                                '
        if isinstance(d, defaultdict):
            d = {k: _default_to_regular(v) for (k, v) in d.items()}
        return d
    return _default_to_regular(self)
