Maximize sharing of function

Use variable (relative to the hierarchy) rather than the absolute
position in the order.