Select based on Hierarachy

I have a Hierarchy as shown below.

I have four labels P1 , P2, P3 and P4
I have many features feat xyz, fea abc, feat pqr and so on
for example as shown feat xyz exists on both P4 and P2 , but I should only consider
feat xyz from P2 since its the higher level in the hierarchy
Same applies for feat abc, it exists in both P3 and P1 , so we just consider feat abc from P1 and disregard it from P3.

i need help writing a select statement to select all features from all the 4 labels, following the above technique.

thanks in advance!!