public Set<Entry<Integer, V>> entrySet() {
        if (entrySet == null) {
            entrySet = new AbstractSet<Entry<Integer, V>>() {
                @Override
                public int size() { // same as Map
                    return IntTreePMap.this.size();
                }

                @Override
                public Iterator<Entry<Integer, V>> iterator() {
                    return root.iterator();
                }

                @Override
                public boolean contains(Object e) {
                    if (!(e instanceof Entry))
                        return false;
                    V value = get(((Entry<?, ?>) e).getKey());
                    return value != null && value.equals(((Entry<?, ?>) e).getValue());
                }
            };
        }
        return entrySet;
    }