func (k *Key) marshal(b *bytes.Buffer) {
	if k.parent != nil {
		k.parent.marshal(b)
	}
	b.WriteByte('/')
	b.WriteString(k.kind)
	b.WriteByte(',')
	if k.stringID != "" {
		b.WriteString(k.stringID)
	} else {
		b.WriteString(strconv.Itoa64(k.intID))
	}
}
marshal marshals the key's string representation to the buffer.
package datastore
import (
	"bytes"
	"encoding/base64"
	"errors"
	"gob"
	"strconv"
	"strings"
	"appengine"
	"goprotobuf.googlecode.com/hg/proto"
	pb "appengine_internal/datastore"
)
type Key struct {
	kind     string
	stringID string
	intID    int64
	parent   *Key
	appID    string
}
func (k *Key) Kind() string {
	return k.kind
}
func (k *Key) StringID() string {
	return k.stringID
}
func (k *Key) IntID() int64 {
	return k.intID
}
func (k *Key) Parent() *Key {
	return k.parent
}
func (k *Key) AppID() string {
	return k.appID
}
func (k *Key) Incomplete() bool {
	return k.stringID == "" && k.intID == 0
}
func (k *Key) valid() bool {
	if k == nil {
		return false
	}
	for ; k != nil; k = k.parent {
		if k.kind == "" || k.appID == "" {
			return false
		}
		if k.stringID != "" && k.intID != 0 {
			return false
		}
		if k.parent != nil {
			if k.parent.Incomplete() {
				return false
			}
			if k.parent.appID != k.appID {
				return false
			}
		}
	}
	return true
}
func (k *Key) Eq(o *Key) bool {
	for k != nil && o != nil {
		if k.kind != o.kind || k.stringID != o.stringID || k.intID != o.intID || k.appID != o.appID {
			return false
		}
		k, o = k.parent, o.parent
	}
	return k == o
}
func (k *Key) root() *Key {
	for k.parent != nil {
		k = k.parent
	}
	return k
}