def fill_pix(self, point, old_colour, colour):
        to_fill = [point]
        while to_fill:
            x, y = to_fill.pop()
            self.set_pixel(x, y, colour)
            for nx, ny in [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)]:
                if 0 <= nx < self.size[0] and 0 <= ny < self.size[1]:
                    if self.pixels[ny][nx] == old_colour:
                        to_fill.append((nx, ny))
Pixel flood-fill. Reliable, but slow.
dataset/ETHPy150Open jerith/depixel/depixel/io_png.py/Bitmap.fill_pix