var ctx = new PrincipalContext(ContextType.Domain);
var userPrincipal = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, userName);
var groups = userPrincipal.GetGroups();
Here you hava all first level group, which current user is associated. If you want to check more deeper, like the groups where first level groups are part of, you must write recursive function which will iterate through whole groups graph.
var ctx = new PrincipalContext(ContextType.Domain);
var groupPrincipal = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, childGroup.SamAccountName);
var currentLevelGroups = groupPrincipal.GetGroups();
Using these three lines you can get the parent groups of specified group.
You can check in every step whether given group is part of collected groups, if yes just break and return true.