Index: src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
===================================================================
--- src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(revision 18225)
+++ src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(working copy)
@@ -60,6 +60,7 @@
     private MapCSSStyleIndex indexData;
     private final Map<MapCSSRule, MapCSSTagCheckerAndRule> ruleToCheckMap = new HashMap<>();
     private static final Map<IPrimitive, Area> mpAreaCache = new HashMap<>();
+    private static final Set<IPrimitive> toMatchForSurrounding = new HashSet<>();
     static final boolean ALL_TESTS = true;
     static final boolean ONLY_SELECTED_TESTS = false;
 
@@ -160,8 +161,9 @@
             indexData = createMapCSSTagCheckerIndex(checks, includeOtherSeverity, ALL_TESTS);
         }
 
-        Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null);
+        final Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null);
         env.mpAreaCache = mpAreaCache;
+        env.toMatchForSurrounding = toMatchForSurrounding;
 
         Iterator<MapCSSRule> candidates = indexData.getRuleCandidates(p);
         while (candidates.hasNext()) {
@@ -219,6 +221,7 @@
         final List<TestError> r = new ArrayList<>();
         final Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null);
         env.mpAreaCache = mpAreaCache;
+        env.toMatchForSurrounding = toMatchForSurrounding;
         for (Set<MapCSSTagCheckerRule> schecks : checksCol) {
             for (MapCSSTagCheckerRule check : schecks) {
                 boolean ignoreError = Severity.OTHER == check.getSeverity() && !includeOtherSeverity;
@@ -368,6 +371,7 @@
         // always clear the cache to make sure that we catch changes in geometry
         mpAreaCache.clear();
         ruleToCheckMap.clear();
+        toMatchForSurrounding.clear();
         super.endTest();
     }
 
@@ -387,6 +391,7 @@
         }
 
         mpAreaCache.clear();
+        toMatchForSurrounding.clear();
 
         Set<OsmPrimitive> surrounding = new HashSet<>();
         for (Entry<String, Set<MapCSSTagCheckerRule>> entry : checks.entrySet()) {
@@ -467,6 +472,8 @@
             }
         }
 
+        toMatchForSurrounding.clear();
+        toMatchForSurrounding.addAll(tested);
         for (OsmPrimitive p : surrounding) {
             if (tested.contains(p))
                 continue;
Index: src/org/openstreetmap/josm/gui/mappaint/Environment.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/Environment.java	(revision 18225)
+++ src/org/openstreetmap/josm/gui/mappaint/Environment.java	(working copy)
@@ -88,6 +88,11 @@
     public Map<IPrimitive, Area> mpAreaCache;
 
     /**
+     * Can be null, may contain primitives when surrounding objects of the primitives are tested
+     */
+    public Set<IPrimitive> toMatchForSurrounding;
+
+    /**
      * Creates a new uninitialized environment.
      */
     public Environment() {
@@ -140,6 +145,7 @@
         this.intersections = other.intersections;
         this.crossingWaysMap = other.crossingWaysMap;
         this.mpAreaCache = other.mpAreaCache;
+        this.toMatchForSurrounding = other.toMatchForSurrounding;
     }
 
     /**
Index: src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(revision 18225)
+++ src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(working copy)
@@ -377,8 +377,10 @@
                 } else {
                     toIgnore = null;
                 }
-
+                boolean filterWithTested = e.toMatchForSurrounding != null && !e.toMatchForSurrounding.isEmpty();
                 for (IPrimitive p : primitives) {
+                    if (filterWithTested && !e.toMatchForSurrounding.contains(p))
+                        continue;
                     if (isPrimitiveUsable(p) && Objects.equals(layer, OsmUtils.getLayer(p))
                             && left.matches(new Environment(p).withParent(e.osm)) && isArea(p)
                             && (toIgnore == null || !toIgnore.contains(p))) {
