title: Tree of different nodes types
body: <p>i want to build a Tree structure in C# where each node is a Wrapper of a generic type T. But i need that the hierarchical relation in the tree is not binded with the type of T. i.</p>
  
  <pre><code>Interface INode&lt;T&gt; : Where T: AbstractNodeContent{
     T Value{get;set;}
     IList&lt;INode&lt;AbstractNodeContent&gt;&gt; Children {get;set;}
     INode&lt;AbstractNodeContent&gt; Parent {get;set;}
  }
  class abstract AbstractNodeContent{
  }
  class Region : AbstractNodeContent{
  }
  NodeRegion : INode&lt;Region&gt;{
  
     // field
  
     // contructor
  
     INode&lt;AbstractNodeContent&gt; getRoot(){
         return (i am root)? this : Parent.getRoot(); // compiler-error
     }
  }
  </code></pre>
  
  <p>I tried a lot of different solution but i always got stuck here and i cannot figure out what im missing.
  The problem it is that in the above function getRoot() i don't know of which type is the root Node so i need an INode&lt; AbstractNodeContent> in return of the function so the when im returning this i have a compiler error saying that i cannot cast from this to INode&lt; AbstractNodeContent>. </p>
  
  <p>Does it is an achievable result or i have to rethink the design? I like the idea of having a tree of diffent type. Can you please give some advice on how think this type of design and how to implement it?</p>
  
  <p>Thanks.
  Luca Colombini</p>