Index: src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
===================================================================
--- src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(revision 17502)
+++ src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(working copy)
@@ -79,6 +79,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;
 
@@ -651,6 +652,7 @@
 
         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()) {
@@ -728,6 +730,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<TagCheck> schecks : checksCol) {
             for (TagCheck check : schecks) {
                 boolean ignoreError = Severity.OTHER == check.getSeverity() && !includeOtherSeverity;
@@ -877,6 +880,7 @@
         // always clear the cache to make sure that we catch changes in geometry
         mpAreaCache.clear();
         ruleToCheckMap.clear();
+        toMatchForSurrounding.clear();
         super.endTest();
     }
 
@@ -887,6 +891,7 @@
         }
 
         mpAreaCache.clear();
+        toMatchForSurrounding.clear();
 
         Set<OsmPrimitive> surrounding = new HashSet<>();
         for (Entry<String, Set<TagCheck>> entry : checks.entrySet()) {
@@ -966,6 +971,8 @@
             }
         }
 
+        toMatchForSurrounding.clear();
+        toMatchForSurrounding.addAll(tested);
         for (OsmPrimitive p : surrounding) {
             if (tested.contains(p))
                 continue;
@@ -986,6 +993,7 @@
      */
     public void runOnly(String ruleFile, Collection<OsmPrimitive> selection) {
         mpAreaCache.clear();
+        toMatchForSurrounding.clear();
 
         Set<OsmPrimitive> surrounding = new HashSet<>();
         for (Entry<String, Set<TagCheck>> entry : checks.entrySet()) {
Index: src/org/openstreetmap/josm/gui/mappaint/Environment.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/Environment.java	(revision 17502)
+++ 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 17502)
+++ src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(working copy)
@@ -368,8 +368,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))) {
