public List<ElementInstance> getFirstIndexes() {
        List<ElementInstance> competitors = new ArrayList<>();
        for (ResourceInstance currentRI : this.resources){
            ElementInstance first = currentRI.getKeys().get(0);
            ElementInstance last = currentRI.getKeys().get(currentRI.getKeys().size()-1);
            if(first.compareTo(last)>0)
                competitors.add(last);
            else
                competitors.add(first);
        }
        List<ElementInstance> result = new ArrayList<>();
        ElementInstance first = competitors.get(0);
        result.add(first);
        for(ElementInstance ei : competitors) {
            if (first.compareTo(ei) > 0) {
                result = new ArrayList<>();
                first = ei;
                if(!result.contains(first))
                    result.add(first);
            } else if(first.compareTo(ei) == 0){
                if(!result.contains(ei))
                    result.add(ei);
            }
        }
        return result;
    }