   settings = getSettings()
   template = @
   loadTree(@)
-  $tree = getTreeElement(@)
 
   # Only a reactive cursor can observe for changes. A simple array can only render a tree once.
   return unless cursor

        # to be removed.
        return unless node
        removeSelection(template, [id])
        $tree.tree('removeNode', node)

TemplateClass.destory = ->

  treeArgs.onCreateLi = onCreateNode.bind(null, template)
  $tree.tree(treeArgs)

# TODO(aramk) Put into utility.
debounceLeft = (func, delay) ->
  isPressed = true
  handle = null
  press = ->
    isPressed = true
    setTimeout((-> isPressed = false), delay)
  wrapped = ->
    if isPressed
      press()
      return
    result = func.apply(null, arguments)
    press()
    result
  wrapped

refreshTree = debounceLeft(loadTree, 1000)

####################################################################################################
# EXPANSION
