code: func (s *parentStack) trim(parents []string) error {
  	split := 0
  	for ; split < len(parents) && split < len(s.stack); split++ {
  		if parents[split] != s.stack[split] {
  			break
  		}
  	}
  	for i := len(s.stack) - 1; i >= split; i-- {
  		if err := s.p.writeEnd(Name{Local: s.stack[i]}); err != nil {
  			return err
  		}
  	}
  	s.stack = parents[:split]
  	return nil
  }
docs: // trim updates the XML context to match the longest common prefix of the stack
  // and the given parents.  A closing tag will be written for every parent
  // popped.  Passing a zero slice or nil will close all the elements.