should `key` be `kde`?  Either that or you need to move this up since `key->` already happened, making the NULL check useless.