   keepNodes(body, allNodesToKeep)
   return
 
-getTemporaryNodes = (body)->
-  node for node in body.querySelectorAll('[data-turbolinks-temporary]')
-
-getPermanentNodes = ->
-  node for node in body.querySelectorAll('[data-turbolinks-permanent]')
-
-getNodesMatchingChangeKeys = (keys, body) ->
+findNodes = (body, selector) ->
+  node for node in body.querySelectorAll(selector)
+
+findNodesMatchingKeys = (body, keys) ->
   matchingNodes = []
   for key in keys
-    for node in body.querySelectorAll('[id^="'+key+'"]')
-      matchingNodes.push(node)
+    matchingNodes.push(findNodes(body, '[id^="'+key+'"]')...)
+
   return matchingNodes
 
 changeNodes = (allNodesToBeChanged, body) ->

  pageCacheKeys = Object.keys pageCache

  cacheTimesRecentFirst = pageCacheKeys.map (url) ->
    pageCache[url].cachedAt
  .sort (a, b) -> b - a

  for key in pageCacheKeys when pageCache[key].cachedAt <= cacheTimesRecentFirst[limit]

  sourceBody = options.body || body

  if options.change
    nodesToBeChanged = findNodes(document.body, '[data-turbolinks-temporary]')
    nodesToBeChanged.push(findNodesMatchingKeys(document.body, options.change)...)
    changedNodes = changeNodes(nodesToBeChanged, sourceBody)
    setAutofocusElement() if anyAutofocusElement(changedNodes)
    changedNodes
  else
    unless options.flush
      nodesToBeChanged = findNodes(document.body, '[data-turbolinks-temporary]')
      changeNodes(nodesToBeChanged, sourceBody)
      persistPermanentNodes(sourceBody, document.body)
      if options.keep
        refreshAllExceptWithKeys(options.keep, sourceBody, document.body)
