What would be the best way to add new type of height check to a grid graph?

My favorite four words to hear when I’m responding to questions here :relieved::relieved:

This has come up a few times- the islands problem. This thread here has some solutions that have helped other users.