code: func (s *SyncState) RemoveResourceIfEmpty(addr addrs.AbsResource) bool {
  	s.lock.Lock()
  	defer s.lock.Unlock()
  
  	ms := s.state.Module(addr.Module)
  	if ms == nil {
  		return true // nothing to do
  	}
  	rs := ms.Resource(addr.Resource)
  	if rs == nil {
  		return true // nothing to do
  	}
  	if len(rs.Instances) != 0 {
  		// We don't check here for the possibility of instances that exist
  		// but don't have any objects because it's the responsibility of the
  		// instance-mutation methods to prune those away automatically.
  		return false
  	}
  	ms.RemoveResource(addr.Resource)
  	s.maybePruneModule(addr.Module)
  	return true
  }
docs: // RemoveResourceIfEmpty is similar to RemoveResource but first checks to
  // make sure there are no instances or objects left in the resource.
  //
  // Returns true if the resource was removed, or false if remaining child
  // objects prevented its removal. Returns true also if the resource was
  // already absent, and thus no action needed to be taken.