It is not recommended to to do all processing within a single LINQ. The Main Building blocks could look like this:
Grouping the data with a LINQ and processing the group and its members within a for each
Checking the types we can do:
the sample was done for the first group
for other group processing find some starter help here:
Intro_GroupBy1Col_grpProcessing.xaml (13.0 KB)
Also have a look here: