Fix bug where array based path recursion uses the same reference