private static Pair<Boolean, Boolean> checkRegionReferences(MasterServices services,
    TableName tableName, RegionInfo region) throws IOException {
    if (region == null) {
      return new Pair<>(Boolean.FALSE, Boolean.FALSE);
    }

    FileSystem fs = services.getMasterFileSystem().getFileSystem();
    Path rootdir = services.getMasterFileSystem().getRootDir();
    Path tabledir = CommonFSUtils.getTableDir(rootdir, tableName);
    Path regionDir = new Path(tabledir, region.getEncodedName());

    try {
      if (!CommonFSUtils.isExists(fs, regionDir)) {
        return new Pair<>(Boolean.FALSE, Boolean.FALSE);
      }
    } catch (IOException ioe) {
      LOG.error("Error trying to determine if region exists, assuming exists and has references",
        ioe);
      return new Pair<>(Boolean.TRUE, Boolean.TRUE);
    }

    TableDescriptor tableDescriptor = services.getTableDescriptors().get(tableName);
    try {
      HRegionFileSystem regionFs = HRegionFileSystem
        .openRegionFromFileSystem(services.getConfiguration(), fs, tabledir, region, true);
      ColumnFamilyDescriptor[] families = tableDescriptor.getColumnFamilies();
      boolean references = false;
      for (ColumnFamilyDescriptor cfd : families) {
        StoreFileTracker sft = StoreFileTrackerFactory.create(services.getConfiguration(),
          tableDescriptor, ColumnFamilyDescriptorBuilder.of(cfd.getNameAsString()), regionFs);
        references = references || sft.hasReferences();
        if (references) {
          break;
        }
      }
      return new Pair<>(Boolean.TRUE, references);
    } catch (IOException e) {
      LOG.error("Error trying to determine if region {} has references, assuming it does",
        region.getEncodedName(), e);
      return new Pair<>(Boolean.TRUE, Boolean.TRUE);
    }
  }
Checks if a region still holds references to parent.
@param tableName The table for the region
@param region    The region to check
@return A pair where the first boolean says whether the region directory exists in the
        filesystem and then the second boolean says whether the region has references to a
        parent.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/janitor/CatalogJanitor.java