       delete result.pathInfo.node
     result
 
+  # Return the character range mappings for a given node in the DOM
+  getMappingsForNode: (node) -> @getRangeForPath @getPathTo node
+
   # Get the matching DOM elements for a given set of text ranges
   # (Calles getMappingsForRange for each element in the givenl ist)
   getMappingsForRanges: (ranges, path = null) ->


  performUpdateOnNode: (node, escalating = false) ->
    unless node? then throw new Error "Called performUpdate with a null node!"
    startTime = @timestamp()
    unless escalating then @saveSelection()
    path = @getPathTo node
    pathInfo = @allPaths[path]
    unless pathInfo? then throw new Error "Can not find path info for path " + path
    unless @mappings[path]? then throw new error "Can not find mappings for path " + path
#    if escalating then console.log "(Escalated)"
#    console.log "Updating data about " + path + ": "
    if pathInfo.node is node and pathInfo.content is @getNodeContent node
#      console.log "Good, the node and the overall content is still the same"
#      console.log "Dropping obsolete path info and mappings for children..."
      prefix = path + "/"


  # save the original selection
  saveSelection: ->
    if @oldRanges?
      console.log "Selection saved at:"
      console.log @selectionSaved
      throw new Error "Selection already saved!"
    sel = @rootWin.getSelection()        
#    console.log "Saving selection: " + sel.rangeCount + " ranges."
    @oldRanges = (sel.getRangeAt i) for i in [0 ... sel.rangeCount]
    switch sel.rangeCount
      when 0 then @oldRanges ?= []
      when 1 then @oldRanges = [ @oldRanges ]
    try
      throw new Error "Selection was saved here"
    catch exception
      @selectionSaved = exception.stack

  # restore selection
  restoreSelection: ->
#    console.log "Restoring selection: " + @oldRanges.length + " ranges."
    unless @oldRanges? then throw new Error "No selection to restore."
    sel = @rootWin.getSelection()
    sel.removeAllRanges()
    sel.addRange range for range in @oldRanges
    delete @oldRanges

  # Select the given node (for visual identification), and optionally scroll to it
  selectNode: (node, scroll = false) ->  
