could we collect generic string-collection indices for set and array and only iterate once (above)?

in the iteration above do sth. like ```} else if (value instanceof BytesRef[]) { ...```