You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: syncorder.go
    path of file: ./repos/sealer/vendor/sigs.k8s.io/kustomize/kyaml/order
    
    the code of the file until where you have to start completion: // Copyright 2021 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

package order

import (
	"sigs.k8s.io/kustomize/kyaml/errors"
	"sigs.k8s.io/kustomize/kyaml/yaml"
)

// SyncOrder recursively sorts the map node keys in 'to' node to match the order of
// map node keys in 'from' node at same tree depth, additional keys are moved to the end
// Field order mi
    
func syncOrder(from, to *yaml.RNode) error {
	if from.IsNilOrEmpty() || to.IsNilOrEmpty() {
		return nil
	}
	switch from.YNode().Kind {
	case yaml.DocumentNode:
		// Traverse the child of the documents
		return syncOrder(yaml.NewRNode(from.YNode()), yaml.NewRNode(to.YNode()))
	case yaml.MappingNode:
		return VisitFields(from, to, func(fNode, tNode *yaml.MapNode) error {
			// Traverse each field value
			if fNode == nil || tNode == nil {
				return nil
			}
			return syncOrder(fNode.Value, tNode.Value)
		})
	case yaml.SequenceNode:
		return VisitElements(from, to, func(fNode, tNode *yaml.RNode) error {
			// Traverse each list element
			return syncOrder(fNode, tNode)
		})
	}
	return nil
}