I know it's useless to reply at this point, it's been a long time. I'm not sure why I didn't say this in the first place, but in any data type present in OmniAPI, #exists() will define whether or not the object is both there and available to be interacted with (for example, in widgets it will check if the child isn't null and if the widget is visible). No need for nasty instanceof checks, no need for null checks either ;)
if (getNPCFinder().findClosest("Dwarf").exists()) {
getNPCFinder().getLastFound().attack();
}
else {
log("not there :(");
}
Or, in your case:
NPC monsterX = getNPCFinder().findClosest("Monster X");
if (monsterX.exists()) monsterX.attack();
else if (regionB.contains(myPlayer())) walk(new Path(regionA));
Might be something to look in to ;)