provide a flexible matching function that adapts itself depending
on whether the two scopes are the same or not