               $li.append $span
             do (text) =>
               $li.on 'click', =>
-                if node.is_leaf == '0'
+                if node.is_leaf
+                  @run "q(#{JSON.stringify text})"
+                else
                   @run "find #{JSON.stringify text}"
-                else
-                  @run "q(#{JSON.stringify text})"
+
             $ul.append $li
           $result.append $ul
       promise

          for node in metrics
            $li = $ '<li class="cm-string"/>'
            text = node.path
            text += '*' if node.is_leaf == '0'
            node_parts = text.split '.'
            for part, i in node_parts
              if i > 0

    @value @async ->
      $result = @output()
      promise = graphite.complete(query).then (response) ->
        _.map response.metrics, ({path, name, is_leaf}) -> {path, name, is_leaf: is_leaf == '1'}

      promise._lead_render = ->
        promise.done (metrics) =>
