Index: /trunk/src/org/openstreetmap/josm/data/osm/ChangesetDataSet.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/ChangesetDataSet.java	(revision 14960)
+++ /trunk/src/org/openstreetmap/josm/data/osm/ChangesetDataSet.java	(revision 14961)
@@ -192,4 +192,19 @@
      */
     public ChangesetDataSetEntry getFirstEntry(PrimitiveId id) {
+        return getEntry(id, 0);
+    }
+
+    /**
+     * Replies the last {@link ChangesetDataSetEntry} with id <code>id</code> from this dataset.
+     * null, if there is no such primitive in the data set.
+     * @param id the id
+     * @return the last {@link ChangesetDataSetEntry} with id <code>id</code> from this dataset or null.
+     * @since 14946
+     */
+    public ChangesetDataSetEntry getLastEntry(PrimitiveId id) {
+        return getEntry(id, 1);
+    }
+
+    private ChangesetDataSetEntry getEntry(PrimitiveId id, int n) {
         if (id == null)
             return null;
@@ -199,26 +214,5 @@
         if (val instanceof ChangesetDataSetEntry[]) {
             ChangesetDataSetEntry[] entries = (ChangesetDataSetEntry[]) val;
-            return entries[0];
-        } else {
-            return (ChangesetDataSetEntry) val;
-        }
-    }
-
-    /**
-     * Replies the last {@link ChangesetDataSetEntry} with id <code>id</code> from this dataset.
-     * null, if there is no such primitive in the data set.
-     * @param id the id
-     * @return the last {@link ChangesetDataSetEntry} with id <code>id</code> from this dataset or null.
-     * @since 14946
-     */
-    public ChangesetDataSetEntry getLastEntry(PrimitiveId id) {
-        if (id == null)
-            return null;
-        Object val = entryMap.get(id);
-        if (val == null)
-            return null;
-        if (val instanceof ChangesetDataSetEntry[]) {
-            ChangesetDataSetEntry[] entries = (ChangesetDataSetEntry[]) val;
-            return entries[1];
+            return entries[n];
         } else {
             return (ChangesetDataSetEntry) val;
Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDataSetTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDataSetTest.java	(revision 14960)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDataSetTest.java	(revision 14961)
@@ -57,4 +57,24 @@
 
     /**
+     * Unit test of method {@link ChangesetDataSet#getFirstEntry(PrimitiveId)} and {@link ChangesetDataSet#getLastEntry(PrimitiveId)}.
+     */
+    @Test
+    public void testGetEntry() {
+        final ChangesetDataSet cds = new ChangesetDataSet();
+        HistoryNode prim1 = new HistoryNode(1, 1, true, User.getAnonymous(), 1, new Date(), LatLon.ZERO);
+        cds.put(prim1, ChangesetModificationType.CREATED);
+        HistoryNode prim2 = new HistoryNode(1, 2, true, User.getAnonymous(), 1, new Date(), LatLon.ZERO);
+        prim2.put("highway", "stop");
+        cds.put(prim2, ChangesetModificationType.UPDATED);
+        assertEquals(prim1, cds.getFirstEntry(prim1.getPrimitiveId()).getPrimitive());
+        assertEquals(prim2, cds.getLastEntry(prim1.getPrimitiveId()).getPrimitive());
+        HistoryNode prim3 = new HistoryNode(1, 3, false, User.getAnonymous(), 1, new Date(), null);
+
+        cds.put(prim3, ChangesetModificationType.DELETED);
+        assertEquals(prim1, cds.getFirstEntry(prim1.getPrimitiveId()).getPrimitive());
+        assertEquals(prim3, cds.getLastEntry(prim1.getPrimitiveId()).getPrimitive());
+    }
+
+    /**
      * Unit test of {@link ChangesetModificationType} enum.
      */
