public class Solution {
    public static Map<String, String> createMap() {
        Map<String,String> map = new HashMap<>();
        map.put("Ivan","Rect123");
        map.put("Ivan1","Rect");
        map.put("Ivan2","Rect");
        map.put("Ivan3","Rec");
        map.put("Ivan4","Rect2");
        map.put("Ivan5","Rect11");
        map.put("Ivan6","Rect");
        map.put("Ivan7","Rect5");
        map.put("Ivan8","Rect6");
        map.put("Ivan9","Rect");
        return map;




    }

    public static void removeTheFirstNameDuplicates(Map<String, String> map) {
        Set<String> unique = new HashSet<>();
        Iterator <Map.Entry<String, String>> iterator = map.entrySet().iterator();
        for (Map.Entry<String, String> entry : map.entrySet())
        {

            String b = entry.getValue();
            unique.add(b);
        }
        while(iterator.hasNext())
        {
            Map.Entry<String, String> pair = iterator.next();
            String a = pair.getValue();
            if (unique.contains(a)) removeItemFromMapByValue(map,a);
        }

    }

    public static void removeItemFromMapByValue(Map<String, String> map, String value) {
        Map<String, String> copy = new HashMap<>(map);
        for (Map.Entry<String, String> pair : copy.entrySet()) {
            if (pair.getValue().equals(value)) {
                map.remove(pair.getKey());
            }
        }
    }

    public static void main(String[] args) {
        Map<String,String> map2= createMap();
        removeTheFirstNameDuplicates(map2);
        Iterator <Map.Entry<String, String>> iterator = map2.entrySet().iterator();
        while (iterator.hasNext())
        {
            String a =iterator.next().getValue();
            System.out.println(a+"value from map is "+map2.get(a));
        }


    }
}
вылезает ConcurrentException на 32 строчке и, как следствие, в 50. Ну и в принципе мысль по решению задачи правильная ?