This is not a homework question. Feel free to recommend a better place to post this if necessary. 

Given the following data structure:

```
class Thing
{
    public Thing() 
    {
        this.Things = new List<Thing>();
    }
    public string First { get; set; }

    public string Group { get; set; }

    public List<Thing> Things { get; set; }
}

```

And the following data:

```
var data = new List<Thing>
{
    new Thing { First = "Alex", Group = "Sams" },
    new Thing { First = "John", Group = "Sams" },
    new Thing { First = "", Group = "Sams" },
    new Thing { First = "Sue", Group = "Freds" },
};

```

What's the LINQiest way to re-shape that into a List that looks like this:

```
First = "", Group = Sams
    First = Alex, Group = Sams
    First = John, Group = Sams
First = Sue, Group = Freds

```

Some things to note:

* Note that **Thing** can contain a list of Things.
* Where no **First** is specified, that is assumed to be a parent, and all records containing a **First** with the same **Group** are children.
* Records with no parent per the rule above, are considered parents.

This example shows the desired result:

```
var result = data.Where(p => p.First == "").Select(p => 
{
    p.Things = data.Where(f => f.Group == p.Group).ToList();
    return p;
}).ToList();

result.AddRange(data.Except(result.SelectMany(f => f.Things)).ToList());

```

This also achieves the desired result, but feels a bit long..

```
var result = data
    .GroupBy(p => p.Group)
    .SelectMany(p => p.Where(f => f.First == "" || p.Count() == 1))
    .Select(p => new Thing { First = p.First, Group = p.Group, Things = data
        .Where(f => f.Group == p.Group && f.First != "" && p.First != f.First).ToList() });

```