Retrieving parent process ID within call Activity

Hi Team,

I have two levels of sub-processes implemented as ‘Call Activity’ components in my process model, i.e, A main process, a sub-process A, being called as a ‘Call Activity’ within the main process and another sub-process B being called from within the first sub-process A , as a call Activity again.
I’m able to retrieve the parent process ID from the sub-process A using the API construct execution.getSuperexecution().getProcessInstanceId().
However, when i try to retrieve the same from sub-process B, i.e the second level sub-process using execution.getSuperexecution().getSuperexecution().getProcessInstanceId(), i’m unable to do so and it gives me a form error in the form where i’m invoking this method.

Is it valid to invoke this method in the above format or otherwise is there any other API/method which returns me the parent process ID from a sub-process at the second level?