Generate a recursive JSON representation of the ent.

def _encode(self):
        """Generate a recursive JSON representation of the ent."""
        obj = {k: v for k, v in self.__dict__.items()
               if not k.startswith('_') and type(v) in SAFE_TYPES}
        obj.update({k: v._encode() for k, v in self.__dict__.items()
                   if isinstance(v, Ent)})
        return obj