By Template:

Check if got anything and use it from query above:

By Path: