<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(self, name, cfg, expand=False):
 """Add a configuration object. :param name: Name for later retrieval :param cfg: Configuration object :param expand: Flag for adding sub-configs for each sub-collection. See discussion in method doc. :return: self, for chaining :raises: CreateQueryEngineError (only if expand=True) """

        self._d[name] = cfg
        if expand:
            self.expand(name)
        return self