code: func marshalPlanModules(
  	changes *plans.Changes,
  	schemas *terraform.Schemas,
  	childModules []addrs.ModuleInstance,
  	moduleMap map[string][]addrs.ModuleInstance,
  	moduleResourceMap map[string][]addrs.AbsResourceInstance,
  ) ([]module, error) {
  
  	var ret []module
  
  	for _, child := range childModules {
  		moduleResources := moduleResourceMap[child.String()]
  		// cm for child module, naming things is hard.
  		var cm module
  		// don't populate the address for the root module
  		if child.String() != "" {
  			cm.Address = child.String()
  		}
  		rs, err := marshalPlanResources(changes, moduleResources, schemas)
  		if err != nil {
  			return nil, err
  		}
  		cm.Resources = rs
  
  		if len(moduleMap[child.String()]) > 0 {
  			moreChildModules, err := marshalPlanModules(changes, schemas, moduleMap[child.String()], moduleMap, moduleResourceMap)
  			if err != nil {
  				return nil, err
  			}
  			cm.ChildModules = moreChildModules
  		}
  
  		ret = append(ret, cm)
  	}
  
  	return ret, nil
  }
docs: // marshalPlanModules iterates over a list of modules to recursively describe
  // the full module tree.