Index: src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(revision 14722)
+++ src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(working copy)
@@ -24,8 +24,10 @@
 import java.util.zip.CRC32;

 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.IPrimitive;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.data.osm.search.SearchCompiler;
 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
@@ -519,6 +521,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)
+         * @since xxx
+         */
+        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<>();
+                    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)
+         * @since xxx
+         */
+        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)
+         * @since xxx
+         */
+        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
