code: def to_dict(self):
          
          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
docs: Return a dict representation of KnwKB.