I did little bit of exercise for tree structure data, since I am always struggling with it.

Example I took from my family tree. My grandfathers name was "Stanko" (same as me btw), he had three kids: my fathers name "Velimir", "Svetlana" and "Julka"
My father "Velimir" also had three kids: "Anamaria", "Stanko" and "Nikola"
His sister "Svetlana" had two kids: "Dragan" and "Dragana"
Dragan had one kid "Sanja" and "Dragana" two kids "Jovana" and "Aleksa"
Structure in string looks like this:

```"Stanko|Velimir|Anamaria"
"Stanko|Velimir|Stanko"
"Stanko|Velimir|Nikola"
"Stanko|Velimir|Anamaria|Tatjana"
"Stanko|Svetlana|Dragan"
"Stanko|Svetlana|Dragana"
"Stanko|Julka"
"Stanko|Svetlana|Dragan|Sanja"
"Stanko|Svetlana|Dragana|Jovana"
"Stanko|Svetlana|Dragana|Aleksa"
```
Main code:
```using System.Collections.Generic;

namespace TreeExample
{
class Program
{

static void Main(string[] args)
{
List<string> treeDescriptions = new List<string> { "Stanko|Velimir|Anamaria" };

TreeMethods geni = new TreeMethods();
TreeStructure geniStructure;

geniStructure = geni.CreateStructure(treeDescriptions);

}
}
}
```
Class:
```using System;
using System.Collections.Generic;

namespace TreeExample
{
class TreeStructure
{
public string Name { get; set; }
public List<TreeStructure> Children;
}

class TreeMethods
{
private TreeStructure CreateTree(string structure, TreeStructure parentTree)
{
if (string.IsNullOrWhiteSpace(structure))
{
return null;
}
else
{
string[] levels = structure.Split('|');
if (levels.Length > 1)
structure = structure.Substring(levels[0].Length + 1, structure.Length - levels[0].Length - 1);
else
structure = string.Empty;

if (parentTree is null)
{
parentTree = new TreeStructure();
parentTree.Name = levels[0];

if (!string.IsNullOrWhiteSpace(structure))
{
parentTree.Children = new List<TreeStructure>();
}
}
else if (parentTree.Children is null)
{
if (!string.IsNullOrWhiteSpace(structure))
{
parentTree.Children = new List<TreeStructure>();
}
}
else
{
bool found = false;
foreach (TreeStructure child in parentTree.Children)
{
string[] levelsChildren = structure.Split('|');

if (!(child is null))
{
if (string.Equals(child.Name, levelsChildren[0], StringComparison.InvariantCultureIgnoreCase))
{
CreateTree(structure, child);
}
}
}

foreach (TreeStructure child in parentTree.Children)
{
string[] levelsChildren = structure.Split('|');
if (!(child is null))
{
found = string.Equals(child.Name, levelsChildren[0], StringComparison.InvariantCultureIgnoreCase);
if (found)
{
break;
}
}
}

if (!found && !string.IsNullOrWhiteSpace(structure))
{
}

}
}

//there are no more leafs, go out
return parentTree;
}

public TreeStructure CreateStructure(List<string> structures)
{
TreeStructure treeStructure = null;

foreach (string structure in structures)
{
int level = 0;
string[] rootChildren = structure.Split('|');

treeStructure = CreateTree(structure, treeStructure);
}

return treeStructure;
}

}
}
```