title: How to create object/singleton of generic type in Scala?
body: <p>In the code shown below, how can I convert <code>EmptyTree</code> to object (Singleton) ?</p>
  
  <pre><code>trait Tree[T] {
      def contains(num: T): Boolean
      def inc( num: T ): Tree[T]
    }
  
  
  class EmptyTree[T &lt;% Ordered[T] ] extends Tree[T] {
      def contains(num:T):Boolean = false
      def inc(num:T):Tree[T] = {
          new DataTree(num, new EmptyTree, new EmptyTree)
      }
      override def toString = "."
  }
  
  class DataTree[T &lt;% Ordered[T] ](val x:T, val left:Tree[T], val right:Tree[T]) extends Tree[T] {
  
      def contains(num:T):Boolean = {
          if( num &lt; x ) left.contains(x)
          else if ( num &gt; x ) right.contains(x)
          else true
      }
      def inc(num:T):Tree[T] = {
          if(num &lt; x ) new DataTree(x, left.inc(num), right)
          else if ( num &gt; x ) new DataTree(x, left, right.inc(num))
          else this
      }
      override def toString = "{" + left + x + right + "}"
  }
  
  
  val t = new DataTree(20, new EmptyTree[Int], new EmptyTree[Int])
                                                  //&gt; t  : greeting.Test.DataTree[Int] = {.20.}
  val p = t.inc(10)                               //&gt; p  : greeting.Test.Tree[Int] = {{.10.}20.}
  val a = p.inc(30)                               //&gt; a  : greeting.Test.Tree[Int] = {{.10.}20{.30.}}
  val s = a.inc(5)                                //&gt; s  : greeting.Test.Tree[Int] = {{{.5.}10.}20{.30.}}
  val m = s.inc(11)                               //&gt; m  : greeting.Test.Tree[Int] = {{{.5.}10{.11.}}20{.30.}}
  </code></pre>