I think you have declared
Map map = new TreeMap();
you need to instead do
TreeMap map = new TreeMap(); //OR SortedMap map = new TreeMap()
map.firstKey();
Because firstKey()
is a method which exists in TreeMap
which is not defined in Map
contract (or interface)