Index: trunk/src/org/openstreetmap/josm/command/PurgeCommand.java
===================================================================
--- trunk/src/org/openstreetmap/josm/command/PurgeCommand.java	(revision 13512)
+++ trunk/src/org/openstreetmap/josm/command/PurgeCommand.java	(revision 13513)
@@ -160,6 +160,6 @@
     public static List<OsmPrimitive> topoSort(Collection<OsmPrimitive> sel) {
         Set<OsmPrimitive> in = new HashSet<>(sel);
-
         List<OsmPrimitive> out = new ArrayList<>(in.size());
+        Set<Relation> inR = new HashSet<>();
 
         // Nodes not deleted in the first pass
@@ -201,4 +201,6 @@
                 }
                 out.add(w);
+            } else if (u instanceof Relation) {
+                inR.add((Relation) u);
             }
         }
@@ -207,11 +209,6 @@
             throw new AssertionError("topo sort algorithm failed (nodes remaining)");
 
-        /**
-          * Rest are relations. Do topological sorting on a DAG where each
-          * arrow points from child to parent. (Because it is faster to
-          * loop over getReferrers() than getMembers().)
-          */
-        @SuppressWarnings({ "unchecked", "rawtypes" })
-        Set<Relation> inR = (Set) in;
+        // Do topological sorting on a DAG where each arrow points from child to parent.
+        //  (Because it is faster to loop over getReferrers() than getMembers().)
 
         Map<Relation, Integer> numChilds = new HashMap<>();
