Index: src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(revision 14430)
+++ src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(working copy)
@@ -519,6 +519,55 @@
         }
 
         /**
+         * Gets a list of all OSM id's of the object's parent(s) with a specified key.
+         *
+         * @param env the environment
+         * @param key the OSM key
+         * @param keyValue the regex value of the OSM key
+         * @return a list of non-null values of the OSM id's from the object's parent(s)
+         */
+	public static List<Long> parent_osm_ids(final Environment env, String key, String keyValue) {
+            if (env.parent == null) {
+                if (env.osm != null) {
+                    final ArrayList<Long> ids = new ArrayList<>();
+                    //final Collection<Long> ids = new TreeSet<>();
+                    //final Collection<Long> ids = new Collection<>();
+                    // we don't have a matched parent, so just search all referrers
+                    for (IPrimitive parent : env.osm.getReferrers()) {
+                        Long value = parent.getUniqueId();
+                        if (value != null && (key == null || parent.get(key) != null)
+                                && (keyValue == null || regexp_test(keyValue, parent.get(key)))) {
+                                ids.add(value);
+                        }
+                    }
+                    return new ArrayList<>(ids);
+                }
+                return Collections.emptyList();
+            }
+            return Collections.singletonList(parent_osm_id(env));
+        }
+
+        /**
+         * Gets a list of all OSM id's of the object's parent(s) with a specified key.
+         *
+         * @param env the environment
+         * @param key the OSM key
+         * @return a list of non-null values of the OSM id's from the object's parent(s)
+         */
+        public static List<Long> parent_osm_ids(final Environment env, String key) { // NO_UCD (unused code)
+		return parent_osm_ids(env, key, null);
+        }
+        /**
+         * Gets a list of all OSM id's of the object's parent(s).
+         *
+         * @param env the environment
+         * @return a list of non-null values of the OSM id's from the object's parent(s)
+         */
+        public static List<Long> parent_osm_ids(final Environment env) {
+		return parent_osm_ids(env, null, null);
+	}
+
+        /**
          * Determines whether the object has a tag with the given key.
          * @param env the environment
          * @param key the OSM key
