I might be a bit late with this information…
The Sandbox has a great Group class that can be used to extract nested group members. I have implemented my own algorithm for this, but the one in the Sandbox contains checking of illegal nested groups (that is group1 is a member in group2 and group2 is a member in group1).