NaN is floating point. So something = if (condition): foo else: bar can't work if 'foo' is of different type than the type of 'bar'.
You can use if (condition): Cell(x:j+1, y:i) else: Cell(-1, -1) or another "special Cell" to indicate what you wanted to indicate using NaN.