         dataType: "json"
         success: (result) =>
           @_renderTree @tree, result
+          @select @opts.selected if @opts.selected
     else
       @_renderTree @tree, @opts.items
+      @select @opts.selected if @opts.selected
 
     @_bind()
 


  select: ($node) ->
    if $node
      $node = @tree.find('.node[data-id=' + $node ']') unless typeof $node is 'object'
      @tree.find('.node.selected').removeClass('selected')
      $node.addClass('selected')
      @tree.trigger "nodeselected", [$node, $node.data("node")]
    else
      $node = @tree.find('.node.selected')


  tree: (opts) ->
    return new Tree opts
})


