def to_dict(self):
        """Return a dict representation of KnwKB."""
        mydict = {'id': self.id, 'name': self.name,
                  'description': self.description,
                  'kbtype': self.kbtype}
        if self.kbtype == 'd':
            mydict.update((self.kbdefs.to_dict() if self.kbdefs else {}) or {})

        return mydict