For posterity, this is what I ended up with:
function ISPlumbHelperCursor2:isValid(square)
local x,y,z = square:getX(),square:getY(),square:getZ()-1
local squareA = getCell():getGridSquare(x, y, z)
if not squareA then return false end
local objects = squareA:getObjects()
for index=0, objects:size()-1 do
local object = objects:get(index)
if (object:hasModData() and object:getModData().canBeWaterPiped) or (instanceof(object, "IsoObject") and object:getSprite() and
object:getSprite():getProperties() and object:getSprite():getProperties():Is(IsoFlagType.waterPiped)) then
return true
end
end
return false
end