Yes. I should probably point out first that Mathias has rather nicely added some good information in the Pathfinder forum on this. Check it out here:
http://forums.wolflair.com/showthread.php?t=21688
Anyway, as to the condition, I think that's what you are looking for. I assume you are concerned about racial HD being included. Races with racial HD add the tag "Classes.Race" to the hero a number of times equal to their HD, so counting the class tags should be equal to the HD. Let me know if I've missed something.
As to your second question, I don't see why not. Traits add a tag to the hero, so if you wanted the trait Abrasive for your pre-req, you could do this:
Code:
hero.tagis[HasTrait.trAbrasive] <> 0