title: C# algorithm for generating hierarchy
body: <p>I've got a text file that looks like this:</p>
  
  <pre><code>{ Id = 1, ParentId = 0, Position = 0, Title = "root" }
  { Id = 2, ParentId = 1, Position = 0, Title = "child 1" }
  { Id = 3, ParentId = 1, Position = 1, Title = "child 2" }
  { Id = 4, ParentId = 1, Position = 2, Title = "child 3" }
  { Id = 5, ParentId = 4, Position = 0, Title = "grandchild 1" }
  </code></pre>
  
  <p>I'm looking for a generic C# algorithm that will create an object hierarchy from this. A "Hierarchize" function, if you will, that turns this data into an object hierarchy.</p>
  
  <p>Any ideas?</p>
  
  <p><em>edit</em> I've already parsed the file into .NET objects:</p>
  
  <pre><code>class Node
  {
      public int Id { get; }
      public int ParentId { get; }
      public int Position { get; }
      public string Title { get; }
  }
  </code></pre>
  
  <p>Now I need to actually arrange the objects into an object graph.</p>