<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_debug_color(self, color):
 """ Helper function for color conversion """

        if color is None:
            return debug_pb.Color(r=255, g=255, b=255)
        else:
            r = getattr(color, "r", getattr(color, "x", 255))
            g = getattr(color, "g", getattr(color, "y", 255))
            b = getattr(color, "b", getattr(color, "z", 255))
            if max(r, g, b) <= 1:
                r *= 255
                g *= 255
                b *= 255

            return debug_pb.Color(r=int(r), g=int(g), b=int(b))