Recursively flatten an array.