Index: trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java	(revision 8293)
+++ trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java	(revision 8294)
@@ -11,4 +11,5 @@
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 
@@ -20,4 +21,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.Notification;
 import org.openstreetmap.josm.tools.Shortcut;
 
@@ -39,4 +41,7 @@
     }
 
+    /**
+     * Called when the action is executed.
+     */
     @Override
     public void actionPerformed(ActionEvent e) {
@@ -46,41 +51,38 @@
         List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class);
         List<Way> selectedWays = OsmPrimitive.getFilteredList(selection, Way.class);
+
+        selectedNodes = cleanSelectedNodes(selectedWays, selectedNodes);
+
         List<Way> applicableWays = getApplicableWays(selectedWays, selectedNodes);
 
         if (applicableWays == null) {
-            JOptionPane.showMessageDialog(
-                    Main.parent,
-                    tr("Select at least one node to be disconnected."),
-                    tr("Warning"),
-                    JOptionPane.WARNING_MESSAGE);
+            notify(tr("Select at least one node to be disconnected."),
+                   JOptionPane.WARNING_MESSAGE);
             return;
         } else if (applicableWays.isEmpty()) {
-            JOptionPane.showMessageDialog(Main.parent,
-                    trn("Selected node cannot be disconnected from anything.",
-                        "Selected nodes cannot be disconnected from anything.",
-                        selectedNodes.size()),
-                    tr("Warning"),
-                    JOptionPane.WARNING_MESSAGE);
+            notify(trn("Selected node cannot be disconnected from anything.",
+                       "Selected nodes cannot be disconnected from anything.",
+                       selectedNodes.size()),
+                   JOptionPane.WARNING_MESSAGE);
             return;
         } else if (applicableWays.size() > 1) {
-            JOptionPane.showMessageDialog(Main.parent,
-                    trn("There is more than one way using the node you selected. Please select the way also.",
-                        "There is more than one way using the nodes you selected. Please select the way also.",
-                        selectedNodes.size()),
-                    tr("Warning"),
-                    JOptionPane.WARNING_MESSAGE);
+            notify(trn("There is more than one way using the node you selected. "
+                       + "Please select the way also.",
+                       "There is more than one way using the nodes you selected. "
+                       + "Please select the way also.",
+                       selectedNodes.size()),
+                   JOptionPane.WARNING_MESSAGE);
             return;
         } else if (applicableWays.get(0).getRealNodesCount() < selectedNodes.size() + 2) {
             // there is only one affected way, but removing the selected nodes would only leave it
             // with less than 2 nodes
-            JOptionPane.showMessageDialog(Main.parent,
-                    trn("The affected way would disappear after disconnecting the selected node.",
-                        "The affected way would disappear after disconnecting the selected nodes.",
-                        selectedNodes.size()),
-                    tr("Warning"),
-                    JOptionPane.WARNING_MESSAGE);
+            notify(trn("The affected way would disappear after disconnecting the "
+                       + "selected node.",
+                       "The affected way would disappear after disconnecting the "
+                       + "selected nodes.",
+                       selectedNodes.size()),
+                   JOptionPane.WARNING_MESSAGE);
             return;
         }
-
 
         // Finally, applicableWays contains only one perfect way
@@ -92,6 +94,59 @@
     }
 
-    // Find ways to which the disconnect can be applied. This is the list of ways with more
-    // than two nodes which pass through all the given nodes, intersected with the selected ways (if any)
+    /**
+     * Send a notification message.
+     * @param msg Message to be sent.
+     * @param messageType Nature of the message.
+     */
+    public void notify(String msg, int messageType) {
+        new Notification(msg).setIcon(messageType).show();
+    }
+
+    /**
+     * Removes irrelevant nodes from user selection.
+     *
+     * The action can be performed reliably even if we remove :
+     *   * Nodes not referenced by any ways
+     *   * When only one way is selected, nodes not part of this way (#10396).
+     *
+     * @param selectedWays  List of user selected way.
+     * @param selectedNodes List of user selected nodes.
+     * @return New list of nodes cleaned of irrelevant nodes.
+     */
+    private List<Node> cleanSelectedNodes(List<Way> selectedWays,
+                                          List<Node> selectedNodes) {
+        List<Node> resultingNodes = new LinkedList<>();
+
+        // List of node referenced by a route
+        for (Node n: selectedNodes) {
+            if (n.isReferredByWays(1)) {
+                resultingNodes.add(n);
+            }
+        }
+        // If exactly one selected way, remove node not referencing par this way.
+        if (selectedWays.size() == 1) {
+            Way w = selectedWays.get(0);
+            for (Node n: new ArrayList<Node>(resultingNodes)) {
+                if (!w.containsNode(n)) {
+                    resultingNodes.remove(n);
+                }
+            }
+        }
+        // Warn if nodes were removed
+        if (resultingNodes.size() != selectedNodes.size()) {
+            notify(tr("Some irrelevant nodes have been removed from the selection"),
+                   JOptionPane.INFORMATION_MESSAGE);
+        }
+        return resultingNodes;
+    }
+
+    /**
+     * Find ways to which the disconnect can be applied. This is the list of ways
+     * with more than two nodes which pass through all the given nodes, intersected
+     * with the selected ways (if any)
+     * @param selectedWays List of user selected ways.
+     * @param selectedNodes List of user selected nodes.
+     * @return List of relevant ways
+     */
     private List<Way> getApplicableWays(List<Way> selectedWays, List<Node> selectedNodes) {
         if (selectedNodes.isEmpty())
