@SuppressWarnings("unchecked")
  public static <K, V> Map<K, V> mapByKey(String key, List<?> list) {
    Map<K, V> map = new HashMap<>();
    if (CollectionUtils.isEmpty(list)) {
      return map;
    }
    try {
      Class<?> clazz = list.get(0).getClass();
      Field field = deepFindField(clazz, key);
      if (field == null) {
          throw new IllegalArgumentException("Could not find the key");
      }
      field.setAccessible(true);
      for (Object o : list) {
        map.put((K) field.get(o), (V) o);
      }
    } catch (Exception e) {
      throw new BeanUtilsException(e);
    }
    return map;
  }
@Test(expected = BeanUtilsException.class)
  public void testMapByKeyNotEmptyListThrowsEx() {
    someAnotherList.add(new KeyClass());
    assertNotNull(BeanUtils.mapByKey("wrongKey", someAnotherList));
  }