Fix gh-27366

Comment From: snicoll

Thanks for the PR @quaff but we don't have parent-first search anywhere else in the codebase. This looks like the right change should be done in Spring Security. If it turns out that they need something at the core level to make that more easy, I am happy to facilitate that.