Take a good look at the snippet below:
a = [1,2,3]
n = 2
puts a.find { |i| i == n }
=> 2
a = [1,2,3]
n = [2]
puts a.find { |i| i == n.shift }
=> nil
Tip: you can see a running version here http://repl.it/OL3
Now explain it. Why the second #find returns nil ?
path.dup.shiftpath[-1]orpath.last.#shiftshiftdoes make sense.f.elements.find {|e| e['name'] == path[0]}