code:     public XMSSPrivateKeyParameters getNextKey()
      {
          /* prepare authentication path for next leaf */
          int treeHeight = this.params.getHeight();
          if (this.getIndex() < ((1 << treeHeight) - 1))
          {
              return new XMSSPrivateKeyParameters.Builder(params)
                  .withSecretKeySeed(secretKeySeed).withSecretKeyPRF(secretKeyPRF)
                  .withPublicSeed(publicSeed).withRoot(root)
                  .withBDSState(bdsState.getNextState(publicSeed, secretKeySeed, (OTSHashAddress)new OTSHashAddress.Builder().build())).build();
          }
          else
          {
              return new XMSSPrivateKeyParameters.Builder(params)
                  .withSecretKeySeed(secretKeySeed).withSecretKeyPRF(secretKeyPRF)
                  .withPublicSeed(publicSeed).withRoot(root)
                  .withBDSState(new BDS(params, getIndex() + 1)).build();  // no more nodes left.
          }
      }
  
  