How to separate external and internal contour

Hi, I’m trying to find a way to paint an outer contour without painting all the inner contours.
The goal at the end is to create a game where contours can be filled with colors like a coloring game for children, when I click on an external contour it paints all its internal contours and I want that only the outer contour will be colored and the inner contours will remain in the color they had.

def mouse_call_back(event, x, y, flags, param):  
    index = 0
    if event == cv2.EVENT_LBUTTONDOWN:
        for i in range(0, len(contours)):         
            r = cv2.pointPolygonTest(contours[i], (x, y), False)
            if r > 0:
                index = i
        color = (random.randint(0,255), random.randint(0,255), random.randint(0,255))
        cv2.drawContours(image, contours, index, color, -1)
        cv2.imshow("res", image)

image = cv2.imread('images\Flower.jpg', cv2.IMREAD_COLOR)
image = cv2.resize(image , (400, 400))
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
threshold = cv2.threshold(gray_image, 220, 255, cv2.THRESH_BINARY)[1]
contours = cv2.findContours(threshold, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)[0]

Hello, you will need to use contours_hierarchy

filling can be done like this:

cv2.fillPoly(img, pts =[contours], color=(255,255,255))

then use cv2.RETR_EXTERNAL, not cv2.RETR_TREE

Hey, I’m attaching a gif that describes the problem, you don’t see the mouse cursor, but when I click on a contour that contains another contour, it’s colored unnecessarily.
BTW cv2.RETR_EXTERNAL just coloring all the image.