NSFileManager, enumeratorAtURL and lastPathComponent

Example of a script that use lastPathComponent to filter a directory return POSIX path.

I try other approach to extract the NSResourceKey from the enumeration to search for NSURLNameKey but I find it to be slower and the approach below.

So when will it be a good approach to use:
NSResourceKey in enumeration ??, anyone like to share some example.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

property NSDirectoryEnumerationSkipsHiddenFiles : a reference to current application's NSDirectoryEnumerationSkipsHiddenFiles
property NSDirectoryEnumerationSkipsPackageDescendants : a reference to current application's NSDirectoryEnumerationSkipsPackageDescendants

set thePath to POSIX path of (choose folder)

my searchWithFilename:{"pbs.txt"} inPath:thePath

on searchWithFilename:theName inPath:thePath
	set theURL to current application's |NSURL|'s fileURLWithPath:thePath
	set manager to current application's NSFileManager's defaultManager()
	set directoryEnumerator to (manager's enumeratorAtURL:theURL includingPropertiesForKeys:{} options:((NSDirectoryEnumerationSkipsHiddenFiles as integer) + (NSDirectoryEnumerationSkipsPackageDescendants as integer)) errorHandler:(missing value))'s allObjects()
	set predicate to current application's NSPredicate's predicateWithFormat:"lastPathComponent ==[c] %@" argumentArray:theName
	set anArray to ((directoryEnumerator's |path|)'s filteredArrayUsingPredicate:predicate) as list
end searchWithFilename:inPath: