pdb.gimp_image_select_contiguous_color
is the programatic way - in a Python plug-in - of doing the magic wand. The drawback is that you have to issue suitable starting coordinates for it to work well.
Maye repeating the process in 3 distant points of the image, and if the selection does not diverge by much in two of those, assume that to be the one you want.
The procedure does not return the selection drawable, so you have to get it by issuing
pdb.gimp_image_get_selection afterwards. You will also need to set the threshold by calling pdb.gimp_context_set_sample_threshold
before calling it.
(My suggestion: copy it to another, new image, resize that to an 8x8pixel image, from which you can get the pixel values and compare directly against other selections made);