0 index Array
0 index Array

If the first object is an array, $path is build with a '0' (integer) index, that does not pass the first '$currentpath == ''' ternal.
Force type comparison (!==) and 'cast' 0 to string (sprintf($key))
lukascivil/TreeWalker