Index: trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java	(revision 15554)
+++ trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java	(revision 15555)
@@ -124,5 +124,5 @@
         // try to build a new way which includes all the combined ways
         NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ways);
-        List<Node> path = graph.buildSpanningPath();
+        List<Node> path = graph.buildSpanningPathNoRemove();
         if (path == null) {
             warnCombiningImpossible();
Index: trunk/src/org/openstreetmap/josm/data/osm/NodeGraph.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/NodeGraph.java	(revision 15554)
+++ trunk/src/org/openstreetmap/josm/data/osm/NodeGraph.java	(revision 15555)
@@ -139,4 +139,6 @@
     private final Set<NodePair> edges;
     private int numUndirectedEges;
+    /** counts the number of edges that were added */
+    private int addedEdges;
     private final Map<Node, List<NodePair>> successors = new LinkedHashMap<>();
     private final Map<Node, List<NodePair>> predecessors = new LinkedHashMap<>();
@@ -195,7 +197,6 @@
      */
     public void add(NodePair pair) {
-        if (!edges.contains(pair)) {
-            edges.add(pair);
-        }
+        addedEdges++;
+        edges.add(pair);
     }
 
@@ -290,5 +291,5 @@
     public List<Node> buildSpanningPath() {
         prepare();
-        if(numUndirectedEges > 0 && isConnected()) {
+        if (numUndirectedEges > 0 && isConnected()) {
             // try to find a path from each "terminal node", i.e. from a
             // node which is connected by exactly one undirected edges (or
@@ -311,4 +312,19 @@
 
     /**
+     * Tries to find a path through the graph which visits each edge (i.e.
+     * the segment of a way) exactly once. If the graph was build from overlapping
+     * ways duplicate edges were removed already. This method will return null if
+     * any duplicated edge was removed.
+     *
+     * @return the path; null, if no path was found or duplicated edges were found
+     * @since xxx
+     */
+    public List<Node> buildSpanningPathNoRemove() {
+        if (edges.size() != addedEdges)
+            return null;
+        return buildSpanningPath();
+    }
+
+    /**
      * Find out if the graph is connected.
      * @return true if it is connected.
@@ -321,5 +337,5 @@
         HashSet<Node> visited = new HashSet<>();
         toVisit.add(nodes.iterator().next());
-        while(!toVisit.isEmpty()) {
+        while (!toVisit.isEmpty()) {
             Node n = toVisit.pop();
             if (!visited.contains(n)) {
Index: trunk/test/data/regress/18385/data.osm
===================================================================
--- trunk/test/data/regress/18385/data.osm	(revision 15555)
+++ trunk/test/data/regress/18385/data.osm	(revision 15555)
@@ -0,0 +1,39 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' generator='JOSM'>
+  <node id='-122635' action='modify' visible='true' lat='52.66926046073' lon='12.21392505729' />
+  <node id='-122637' action='modify' visible='true' lat='52.55051305295' lon='13.09798864018' />
+  <node id='-122639' action='modify' visible='true' lat='52.61734809138' lon='13.4565029042' />
+  <node id='-122641' action='modify' visible='true' lat='52.3991399431' lon='13.68057431922' />
+  <node id='-122643' action='modify' visible='true' lat='53.1825599038' lon='11.54578483796' />
+  <node id='-122645' action='modify' visible='true' lat='53.27036137055' lon='13.39946654402' />
+  <node id='-122647' action='modify' visible='true' lat='53.5302652224' lon='13.87612755415' />
+  <node id='-122649' action='modify' visible='true' lat='53.34582398928' lon='14.5035275162' />
+  <node id='-122651' action='modify' visible='true' lat='52.12985665416' lon='14.73167295694' />
+  <node id='-122653' action='modify' visible='true' lat='51.97954756913' lon='12.48688478104' />
+  <node id='-122655' action='modify' visible='true' lat='52.40908200502' lon='13.08169253727' />
+  <node id='-122657' action='modify' visible='true' lat='52.24974002702' lon='13.5746496503' />
+  <node id='-122659' action='modify' visible='true' lat='51.40375250434' lon='13.20798733482' />
+  <node id='-122661' action='modify' visible='true' lat='51.58384268627' lon='14.68278464821' />
+  <way id='-122662' action='modify' visible='true'>
+    <nd ref='-122651' />
+    <nd ref='-122649' />
+    <nd ref='-122647' />
+    <nd ref='-122645' />
+    <nd ref='-122643' />
+    <nd ref='-122635' />
+    <nd ref='-122637' />
+    <nd ref='-122639' />
+    <nd ref='-122641' />
+  </way>
+  <way id='-122663' action='modify' visible='true'>
+    <nd ref='-122641' />
+    <nd ref='-122657' />
+    <nd ref='-122655' />
+    <nd ref='-122637' />
+    <nd ref='-122635' />
+    <nd ref='-122653' />
+    <nd ref='-122659' />
+    <nd ref='-122661' />
+    <nd ref='-122651' />
+  </way>
+</osm>
Index: trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java	(revision 15554)
+++ trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java	(revision 15555)
@@ -3,4 +3,5 @@
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
 import java.io.IOException;
@@ -46,5 +47,5 @@
             DataSet ds = OsmReader.parseDataSet(is, null);
             NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ds.getWays());
-            List<Node> path = graph.buildSpanningPath();
+            List<Node> path = graph.buildSpanningPathNoRemove();
             assertEquals(10, path.size());
             Set<Long> firstAndLastObtained = new HashSet<>();
@@ -55,4 +56,19 @@
             firstAndLastExpected.add(35213705L);
             assertEquals(firstAndLastExpected, firstAndLastObtained);
+        }
+    }
+
+    /**
+     * Non-regression test for bug #1835 (combine way with overlapping ways)
+     * @throws IOException if any I/O error occurs
+     * @throws IllegalDataException if OSM parsing fails
+     */
+    @Test
+    public void testTicket18385() throws IOException, IllegalDataException {
+        try (InputStream is = TestUtils.getRegressionDataStream(18385, "data.osm")) {
+            DataSet ds = OsmReader.parseDataSet(is, null);
+            NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ds.getWays());
+            List<Node> path = graph.buildSpanningPathNoRemove();
+            assertNull(path);
         }
     }
