I would venture to guess that you could loop through the cards just one time - with multiple IF statements in the loop - to check for each type of condition.

Basically add on the the logic that notLKH gave you - keeping in mind that there is a hierarchy to what you find.

I would suggest you sort the cards from low to high order before looping through them - it will make some of the checking even more intuitive.