close window based on kCGWindowName value

but I'm not new to programming. I'm trying to have an always running menubar app listen for a specific window in an application to be opened and then close that window, but not the application. Here is my current approach, it is mostly a mix of other SO answers I found.

How would I go about checking windows for the name I want without casting to a String? I have called print() on all objects in infoList and have seen a kCGWindowName value with the name of the window I am looking for, so I know its there.