Updated do_element_matchup, converting it into a rudimentary recursive function.