MZ Check if event on var X,Y position has "ABC" name?

As title says, can anyone help me with this? I have an events at random positions, I want to check if the event based on defined by variable X, Y position has name, let's say "rock"?
You can call this code line in a Conditional Branch -> Script:
Code:
$gameMap.eventsXy(x, y).length > 0
&& $gameMap.eventsXy(x, y)[0].event().name == "rock"

Replace x y accordingly (2 times here)
It may not work correctly when events are overlapping.
You can call this code line in a Conditional Branch -> Script:
Code:
$gameMap.eventsXy(x, y).length > 0
&& $gameMap.eventsXy(x, y)[0].event().name == "rock"

Replace x y accordingly (2 times here)
It may not work correctly when events are overlapping.
Events will never overlap actually in my case. Thank you so much, will check this out after work.

Original thread: https://forums.rpgmakerweb.com/threads/check-if-event-on-var-x-y-position-has-abc-name.139844/