code: func (s *State) prune() {
  	if s == nil {
  		return
  	}
  
  	// Filter out empty modules.
  	// A module is always assumed to have a path, and it's length isn't always
  	// bounds checked later on. Modules may be "emptied" during destroy, but we
  	// never want to store those in the state.
  	for i := 0; i < len(s.Modules); i++ {
  		if s.Modules[i] == nil || len(s.Modules[i].Path) == 0 {
  			s.Modules = append(s.Modules[:i], s.Modules[i+1:]...)
  			i--
  		}
  	}
  
  	for _, mod := range s.Modules {
  		mod.prune()
  	}
  	if s.Remote != nil && s.Remote.Empty() {
  		s.Remote = nil
  	}
  }
docs: // prune is used to remove any resources that are no longer required