Do you just want to assign the empty hash for the last prefix and current to the previous  (length - 2) prefix?