How to use user security levels in a module?

I am trying to use security levels to control who as access to the methods of the module's script API. I am able to get a user's security level configs through the following code

ClientReqSession session = ClientReqSession.get();
ClientReqSession.User sessionUser = (ClientReqSession.User) session.getAttribute(ClientReqSession.SESSION_USER);
SecurityContext securityContext = SecurityContext.fromAuthenticatedUser(sessionUser.getUser().get());
List<SecurityLevelConfig> securityLevelConfigs = securityContext.getSecurityLevels();

My problem is that security levels share names and SecurityLevelConfigs don't have a means of accessing their path or parent, so how do I check if a user has a specific security level?

If I had the following security levels, how would I tell if a user had access to Test/Default but not Test2/Default?

I think you want to create a PermissionsConfig (ideally, only once), something like:

var permissions = PermissionsConfig.builder(Type.AnyOf).addSecurityLevel("Test", "Default").build();
var isAuthorized = permissions.isAuthorized(securityContext.getSecurityLevels());