Checking and getting a player's permission groups

How can I check if a given player has a permission group of a certain name? Additionally, how can I get all permission groups that contain a given player?

If someone could point me to some code examples, this would be greatly appreciated. I already checked the docs, but the description of Subjects and Subject collections was to specified to answer my question.

You should be able to get this information with Subject#getParents()