How to get ProcessDefinitionKey using rootProcessInstancesId using java api

Hi There,

Is there any way to retrieve ProcessDefinitionKey using rootProcessInstancesId using java api.

I am able to retrieve rootProcessInstancesId using below code and my requirement is to find ProcessDefinitionKey associated with each of the rootProcessInstanceId.

List lists = historyService
.createHistoricProcessInstanceQuery()
.rootProcessInstances()
.list();

Thanks in advance !
Amith