Index: /trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java	(revision 6544)
+++ /trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java	(revision 6544)
@@ -0,0 +1,167 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.TreeSet;
+
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Way;
+
+/**
+ * Auxiliary class for the {@link SelectNonBranchingWaySequencesAction}.
+ *
+ * @author Marko Mäkelä
+ */
+public class SelectNonBranchingWaySequences {
+    /**
+     * outer endpoints of selected ways
+     */
+    TreeSet<Node> outerNodes;
+    /**
+     * endpoints of selected ways
+     */
+    TreeSet<Node> nodes;
+
+    /**
+     * Creates a way selection
+     *
+     * @param ways selection a selection of ways
+     */
+    public SelectNonBranchingWaySequences(final Collection<Way> ways) {
+        if (ways.isEmpty()) {
+            // The selection cannot be extended.
+            outerNodes = null;
+            nodes = null;
+        } else {
+            nodes = new TreeSet<Node>();
+            outerNodes = new TreeSet<Node>();
+
+            for (Way way : ways)
+                addNodes(way);
+        }
+    }
+
+    /**
+     * Add a way endpoint to nodes, outerNodes
+     *
+     * @param node a way endpoint
+     */
+    private void addNodes(Node node) {
+        if (node == null) ;
+        else if (!nodes.add(node))
+            outerNodes.remove(node);
+        else
+            outerNodes.add(node);
+    }
+
+    /**
+     * Add the endpoints of the way to nodes, outerNodes
+     *
+     * @param way a way whose endpoints are added
+     */
+    private void addNodes(Way way) {
+        addNodes(way.firstNode());
+        addNodes(way.lastNode());
+    }
+
+    /**
+     * Find out if the selection can be extended
+     *
+     * @return true if the selection can be extended
+     */
+    public boolean canExtend() {
+        return outerNodes != null && !outerNodes.isEmpty();
+    }
+
+    /**
+     * Finds out if the current selection can be extended.
+     *
+     * @param selection current selection (ways and others)
+     * @param node      perimeter node from which to extend the selection
+     * @return a way by which to extend the selection, or null
+     */
+    private static Way findWay(Collection<OsmPrimitive> selection, Node node) {
+        Way foundWay = null;
+
+        for (Way way : OsmPrimitive.getFilteredList(node.getReferrers(),
+                Way.class)) {
+            if (way.getNodesCount() < 2 || !way.isFirstLastNode(node)
+                    || selection.contains(way))
+                continue;
+
+            /* A previously unselected way was found that is connected
+            to the node. */
+            if (foundWay != null)
+                /* This is not the only qualifying way. There is a
+                branch at the node, and we cannot extend the selection. */
+                return null;
+
+            /* Remember the first found qualifying way. */
+            foundWay = way;
+        }
+
+        /* Return the only way found, or null if none was found. */
+        return foundWay;
+    }
+
+    /**
+     * Finds out if the current selection can be extended.
+     * <p/>
+     * The members outerNodes, nodes must have been initialized.
+     * How to update these members when extending the selection, @see extend().
+     *
+     * @param selection current selection
+     * @return a way by which to extend the selection, or null
+     */
+    private Way findWay(Collection<OsmPrimitive> selection) {
+        for (Node node : outerNodes) {
+            Way way = findWay(selection, node);
+            if (way != null)
+                return way;
+        }
+
+        return null;
+    }
+
+    /**
+     * Extend the current selection
+     *
+     * @param data the data set in which to extend the selection
+     */
+    public void extend(DataSet data) {
+        Collection<OsmPrimitive> currentSelection;
+        LinkedList<OsmPrimitive> selection;
+        boolean selectionChanged = false;
+        Way way;
+
+        if (!canExtend())
+            return;
+
+        currentSelection = data.getSelected();
+
+        way = findWay(currentSelection);
+
+        if (way == null)
+            return;
+
+        selection = new LinkedList<OsmPrimitive>();
+        for (OsmPrimitive primitive : currentSelection)
+            selection.add(primitive);
+
+        do {
+            if (!selection.add(way))
+                break;
+
+            selectionChanged = true;
+            addNodes(way);
+
+            way = findWay(selection);
+        } while (way != null);
+
+        if (selectionChanged)
+            data.setSelected(selection, true);
+    }
+}
Index: /trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequencesAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequencesAction.java	(revision 6544)
+++ /trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequencesAction.java	(revision 6544)
@@ -0,0 +1,48 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.tools.Shortcut;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+/**
+ * This allows to select a sequence of non-branching connected ways.
+ *
+ * @author Marko Mäkelä
+ */
+public class SelectNonBranchingWaySequencesAction extends JosmAction {
+
+    /**
+     * Creates a new {@link SelectNonBranchingWaySequencesAction}
+     *
+     */
+    public SelectNonBranchingWaySequencesAction() {
+        super(tr("Non-branching way sequences"),
+                "way-select",
+                tr("Select non-branching sequences of ways"),
+                Shortcut.registerShortcut("wayselector:wayselect", tr("Non-branching way sequences"), KeyEvent.VK_W, Shortcut.SHIFT),
+                true);
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent ev) {
+        DataSet ds = Main.main.getCurrentDataSet();
+        SelectNonBranchingWaySequences ws = new SelectNonBranchingWaySequences(ds.getSelectedWays());
+        ws.extend(ds);
+    }
+
+    /**
+     * Update the enabled state of the action when something in
+     * the JOSM state changes, i.e. when a layer is removed or
+     * added.
+     */
+    @Override
+    protected void updateEnabledState() {
+        setEnabled(Main.main.getCurrentDataSet() != null);
+    }
+}
Index: /trunk/src/org/openstreetmap/josm/gui/MainMenu.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MainMenu.java	(revision 6543)
+++ /trunk/src/org/openstreetmap/josm/gui/MainMenu.java	(revision 6544)
@@ -78,4 +78,5 @@
 import org.openstreetmap.josm.actions.SaveAsAction;
 import org.openstreetmap.josm.actions.SelectAllAction;
+import org.openstreetmap.josm.actions.SelectNonBranchingWaySequencesAction;
 import org.openstreetmap.josm.actions.SessionLoadAction;
 import org.openstreetmap.josm.actions.SessionSaveAsAction;
@@ -260,4 +261,6 @@
     /** Selection -> Unselect All */
     public final UnselectAllAction unselectAll = new UnselectAllAction();
+    /** Selection -> Non-branching way sequences */
+    public final SelectNonBranchingWaySequencesAction nonBranchingWaySequences = new SelectNonBranchingWaySequencesAction();
 
     /* Audio menu */
@@ -704,4 +707,5 @@
         add(selectionMenu, selectAll);
         add(selectionMenu, unselectAll);
+        add(selectionMenu, nonBranchingWaySequences);
 
         add(toolsMenu, splitWay);
Index: /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 6543)
+++ /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 6544)
@@ -116,5 +116,6 @@
             new DeprecatedPlugin("epsg31287", tr("replaced by new {0} plugin", "proj4j")),
             new DeprecatedPlugin("licensechange", tr("no longer required")),
-            new DeprecatedPlugin("restart", IN_CORE)
+            new DeprecatedPlugin("restart", IN_CORE),
+            new DeprecatedPlugin("wayselector", IN_CORE),
         });
     }
