def _get_nearest_circle(self, x, y):
        if self.event_state == 'normal':  # only check input circles
            left_gutter = self.b + self.r
            if x > left_gutter:  # border + radius
                return None, 0
            for i, circle_y in enumerate(self.left_circle_pos):
                if circle_y - self.r < y and circle_y + self.r > y:
                    return circle_y, i
            return None, 0

        if self.event_state == 'connecting':  # only check output cirlces
            right_gutter = self.w - (self.b + self.r)
            if x < right_gutter:
                return None, 0
            for i, circle_y in enumerate(self.right_circle_pos):
                if circle_y - self.r < y and circle_y + self.r > y:
                    return circle_y, i
            return None, 0
Returns the nearest circle and index or None.
dataset/ETHPy150Open jminardi/RobotBrain/robot_brain/servers/sensor_server/links_component.py/LinksComponent._get_nearest_circle