public static Map<String, Region<?, ?>> getColocatedRegions(final Region<?, ?> r) {
    Map ret;
    if (isPartitionedRegion(r)) {
      final PartitionedRegion pr = (PartitionedRegion) r;
      ret = ColocationHelper.getAllColocationRegions(pr);
      if (ret.isEmpty()) {
        ret = Collections.emptyMap();
      }
    } else if (r instanceof LocalDataSet) {
      LocalDataSet lds = (LocalDataSet) r;
      InternalRegionFunctionContext fc = lds.getFunctionContext();
      if (fc != null) {
        ret = ColocationHelper.getAllColocatedLocalDataSets(lds.getProxy(), fc);
        if (ret.isEmpty()) {
          ret = Collections.emptyMap();
        }
      } else {
        ret = ColocationHelper.getColocatedLocalDataSetsForBuckets(lds.getProxy(),
            lds.getBucketSet());
      }
    } else {
      throw new IllegalArgumentException(
          String.format("Region %s is not a Partitioned Region",
              r.getFullPath()));
    }
    return Collections.unmodifiableMap(ret);
  }
Given a partitioned Region, return a map of
{@linkplain PartitionAttributesFactory#setColocatedWith(String) colocated Regions}. Given a
local data reference to a partitioned region, return a map of local
{@linkplain PartitionAttributesFactory#setColocatedWith(String) colocated Regions}. If there
are no colocated regions, return an empty map.

@param r a partitioned Region
@throws IllegalStateException if the Region is not a {@linkplain DataPolicy#PARTITION
        partitioned Region}
@return an unmodifiable map of {@linkplain Region#getFullPath() region name} to {@link Region}
@since GemFire 6.0
geode-core/src/main/java/org/apache/geode/cache/partition/PartitionRegionHelper.java