public class TreeNode{ public TreeNode() { Children = new List >(); } public void AddChild(TreeNode item) { item.Parent = this; Children.Add(item); } public List > Children { get; set; } public TreeNode Parent { get; set; } public T Data { get; set; } public bool IsLeaf { get { return !Children.Any(); } } }