def deparse(self):
        """Dump the in-memory RiveScript brain as a Python data structure.

        This would be useful, for example, to develop a user interface for
        editing RiveScript replies without having to edit the RiveScript
        source code directly.

        :return dict: JSON-serializable Python data structure containing the
            contents of all RiveScript replies currently loaded in memory.
        """

        # Data to return.
        result = {
            "begin": {
                "global":   {},
                "var":      {},
                "sub":      {},
                "person":   {},
                "array":    {},
                "triggers": [],
            },
            "topics":  {},
        }

        # Populate the config fields.
        if self._debug:
            result["begin"]["global"]["debug"] = self._debug
        if self._depth != 50:
            result["begin"]["global"]["depth"] = 50

        # Definitions
        result["begin"]["var"]    = self._var.copy()
        result["begin"]["sub"]    = self._sub.copy()
        result["begin"]["person"] = self._person.copy()
        result["begin"]["array"]  = self._array.copy()
        result["begin"]["global"].update(self._global.copy())

        # Topic Triggers.
        for topic in self._topics:
            dest = None  # Where to place the topic info

            if topic == "__begin__":
                # Begin block.
                dest = result["begin"]
            else:
                # Normal topic.
                if topic not in result["topics"]:
                    result["topics"][topic] = {
                        "triggers": [],
                        "includes": {},
                        "inherits": {},
                    }
                dest = result["topics"][topic]

            # Copy the triggers.
            for trig in self._topics[topic]:
                dest["triggers"].append(copy.deepcopy(trig))

            # Inherits/Includes.
            for label, mapping in {"inherits": self._lineage, "includes": self._includes}.items():
                if topic in mapping and len(mapping[topic]):
                    dest[label] = mapping[topic].copy()

        return result
Dump the in-memory RiveScript brain as a Python data structure.

        This would be useful, for example, to develop a user interface for
        editing RiveScript replies without having to edit the RiveScript
        source code directly.

        :return dict: JSON-serializable Python data structure containing the
            contents of all RiveScript replies currently loaded in memory.