with mesh you mean shape nodes of type mesh or what normal people call the object namely the dag node just preceding that mesh. Now i guess the later since Maya does not have groups either, a group is just a empty transform. But the vocabulary people use when they call things groups grossly miscategorizes 5 different natural occurrences in Maya. So what you have is parent linkage and group, and object, but then your missing 2 other possible structures. So this makes it a bit overloaded request as i can satisfy your request in 10 different ways which all have really different outcomes.
If you use the standard Maya notational vocabulary and just consider all under the selection as part of the tree then its just simply. Note this is recursive so it will also name children and children children as well.
$selection = `ls -sl`;
$allMeshShapes = `listRelatives -allDescendents -noIntermediate -type mesh $selection`;
$allMeshObjects = `listRelatives -parent $allMeshShapes`;
Stop at whatever definition of mesh that suits you, most users think the trasform is the mesh. If you dont want full recursive use list relatives -children 2 times instead of -allDescendents in the first parent lookup.
Anyway this is sort of hard to define in code because i can not know what you mean by group mays structures do not have it defined in the sort of way thats meaningful*. Anyway this should sort you out whatever you mean by group.
*computers are very specific in meaning so I have no other choice than to speak the same anal retentive language as the computer does. Does not mean i am. But just pointing out that the model computers use ad what you have in yoru head may not always match.