Column comparison including null values using getBackgroundAt event function

Hi, I am using getBackgroundAt() extension function. But could not end up with required result.
if target value is in between min and max value, return target background with green color.
if target value is plus/minus 10 from min and max value, display target background value with yellow color.
if target value is not in between min and max value, target background value with red color.
If min and max is null, return white background.
if one of min or max value is null, then compare with other available value, return respective color

I have tried something like this
if self.data.getValueAt(row, “target”) > data.getValueAt(row, “max”) :
return system.gui.color(“red”)
else:
return system.gui.color(“green”)