docs: @SuppressWarnings("unchecked")
  	private void mergeArrayList(ShardRequest sreq, NamedList<Object> mtasResponse, String key, Integer preferredPurpose,
  			boolean mergeAllShardResponses) {
  		// create new response for key
  		ArrayList<Object> mtasListResponse;
  		Object o = mtasResponse.get(key);
  		if (o instanceof ArrayList) {
  			mtasListResponse = (ArrayList<Object>) o;
  		} else {
  			mtasListResponse = new ArrayList<>();
  			mtasResponse.removeAll(key);
  			mtasResponse.add(key, mtasListResponse);
  		}
  		// collect responses for each shard
  		HashMap<String, ArrayList<Object>> mtasListShardResponses = new HashMap<>();
  		ArrayList<ArrayList<Object>> mtasListShardResponsesExtra = new ArrayList<>();
  		for (ShardResponse response : sreq.responses) {
  			// only continue if new shard or preferred purpose
  			if (mtasListShardResponses.containsKey(response.getShard())
  					&& ((preferredPurpose == null) || (sreq.purpose != preferredPurpose))) {
  				break;
  			}
  			// update
  			try {
  				NamedList<Object> result = response.getSolrResponse().getResponse();
  				ArrayList<Object> data = (ArrayList<Object>) result.findRecursive("mtas", key);
  				if (data != null) {
  					if (mtasListShardResponses.containsKey(response.getShardAddress())) {
  						if (mergeAllShardResponses) {
  							mtasListShardResponsesExtra.add(data);
  						}
  					} else {
  						mtasListShardResponses.put(response.getShardAddress(), data);
  					}
  				}
  			} catch (ClassCastException e) {
  				log.error(e);
  			}
  		}
  
  		try {
  			for (ArrayList<Object> mtasListShardResponse : mtasListShardResponses.values()) {
  				mergeResponsesArrayList(mtasListResponse, mtasListShardResponse);
  			}
  			for (ArrayList<Object> mtasListShardResponse : mtasListShardResponsesExtra) {
  				mergeResponsesArrayList(mtasListResponse, mtasListShardResponse);
  			}
  		} catch (IOException e) {
  			log.error(e);
  		}
  	}