Get top level refID in planned production orders explosion tab


I have created a new field in between Number and reference type in the below screenshot and I am trying to display the topLevel reference itemId. 

In order to achieve it, I am trying to get the top level refId. Please see the below screenshot for better understanding.

I tried with the following steps,

Created a new field in the table ReqTrans -> Created a display method with the following code to get the ToplevelRefID

public static display PoolId displayPool(ReqTrans _this)
        PoolId           poolId;
        ReqPO            reqPO;

        switch (_this.RefType)
            case ReqRefType::BOMLine :
            case ReqRefType::BOMPlannedOrder :
                poolId = ReqPO::find(_this.PlanVersion,_this.RefId).ItemId;

        return poolId;

I have used switch case cos I have other scenarios also dont mind that.

Please help me to achieve this.