     console.log "sizesBuffer", @sizesBuffer.toString()
 
 
+  getNodeIndex : (nodeId) ->
+
+    for i in [0..@nodeIDs.length]
+      if @nodeIDs.get(i) == nodeId
+        return i
+
+
+  doWithNodeIndex : (nodeId, f) ->
+
+    index = @getNodeIndex(nodeId)
+    return unless index?
+    f(index)
+
+
   #### Color utility methods
 
   hexToRGB : (hexColor) ->


  updateNodeColor : (id, isActiveNode, isBranchPoint) ->

    for i in [0..@nodeIDs.length]
      if @nodeIDs.get(i) == id
        @nodesColorBuffer.set(@getColor(id, isActiveNode, isBranchPoint), i)

    @updateGeometries()


  updateNodeRadius : (id, radius) ->

    for i in [0..@nodeIDs.length]
      if @nodeIDs.get(i) == id
        @sizesBuffer.set([radius * 2], i)

    @updateGeometries()


  startNodeHighlightAnimation : (nodeId) ->

    for i in [0..@nodeIDs.length]
      if @nodeIDs.get(i) == nodeId
        index = i

    return unless index?

    normal = 1.0
    highlighted = 2.0

    @animateNodeScale(normal, highlighted, index, =>
      @animateNodeScale(highlighted, normal, index)
    )



      for i in [0...array.elementLength]
        array.getAllElements()[index * array.elementLength + i] = lastElement[i]

    nodesIndex = @getNodeIndex(node.id)
    $.assert(nodesIndex?, "No node found.", { id : node.id, @nodeIDs })

    # swap IDs and nodes
