       path = path.split '.'
     else
       path = path.slice()
-    while ref? and prop = path.shift()
+    # while ref? and prop = path.shift()
+    for ref, prop in path
      ref = ref[prop]
     ref
   ###

    last = path.pop()
    prev = []
    ref = obj
    while component = path.shift()
      if primTypes.test typeof ref[component]
        throw new Error \
          """

      path = path.slice()
    prev = []
    last = path.pop()
    # while component = path.shift()
    for component in path
      if primTypes.test typeof ref[component]
        throw new Error \
          """
