How to query tasks in subprocess using the intance id

Currently, I store the instance ID of a process in my application, and retrieve information about tasks within the process when needed using the following approach:

List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery( )
.processInstanceId(processInstanceId).list()
//do something

Now, I am planning to use subprocesses where the instance IDs may be different. Is there a good way for me to retrieve all historical tasks by using the instance ID of the root process? Or to obtain the instance IDs of all subprocesses?