Recursively detect element type of an array.