Check if folder is already open in Finder

I try to check if folder x is already open in Finder.

My script opens lots of folders and many of those are already open and some are minimized to Dock and i don’t want to open folder if it is already open, because then it unminimizes from Dock.

Perhaps something like this:

set x to choose folder without invisibles
set y to name of (info for x)
tell application "Finder"
	if exists window y then
		say "this folder is already open"
	else
		say "this folder is not open"
	end if
end tell

Or you can get and test the folder’s window directly:

set x to choose folder without invisibles
tell application "Finder"
	set windowIsOpen to (window of x exists)
end tell