Optimized matching

a few comments in here wouldn't hurt. I am admittedly tired, but I have trouble following what happens exactly in here, even if I understand the general principle. What is row['idx'], the list of ids of the current "cell"?