code: def add_subkey(self, key, **prefs):
          
          if self.is_public:
              raise PGPError("Cannot add a subkey to a public key. Add the subkey to the private component first!")
  
          if key.is_public:
              raise PGPError("Cannot add a public key as a subkey to this key")
  
          if key.is_primary:
              if len(key._children) > 0:
                  raise PGPError("Cannot add a key that already has subkeys as a subkey!")
  
              # convert key into a subkey
              npk = PrivSubKeyV4()
              npk.pkalg = key._key.pkalg
              npk.created = key._key.created
              npk.keymaterial = key._key.keymaterial
              key._key = npk
              key._key.update_hlen()
  
          self._children[key.fingerprint.keyid] = key
          key._parent = self
  
          ##TODO: skip this step if the key already has a subkey binding signature
          bsig = self.bind(key, **prefs)
          key |= bsig
docs: Add a key as a subkey to this key.
          :param key: A private :py:obj:`~pgpy.PGPKey` that does not have any subkeys of its own
  
          :keyword usage: A ``set`` of key usage flags, as :py:obj:`~constants.KeyFlags` for the subkey to be added.
          :type usage: ``set``
  
          Other valid optional keyword arguments are identical to those of self-signatures for :py:meth:`PGPKey.certify`