func indirectAlloc(v reflect.Value) reflect.Value {
loop:
	for {
		switch v.Kind() {
		case reflect.Interface:
			if v.IsNil() {
				v.Set(reflect.MakeMap(reflect.TypeOf(Map{})))
			}
			v = v.Elem()
		case reflect.Ptr:
			if v.IsNil() {
				v.Set(reflect.New(v.Type().Elem()))
			}
			v = v.Elem()
		case reflect.Map:
			if v.IsNil() {
				v.Set(reflect.MakeMap(v.Type()))
			}
			break loop
		case reflect.Slice:
			if v.IsNil() {
				v.Set(reflect.MakeSlice(v.Type(), v.Len(), 0))
			}
			break loop
		default:
			break loop
		}
	}
	return v
}
indirectAlloc indirects all interfaces/pointers and allocates a value if
needed. If value is nil then a Map is allocated.
package bson
import (
	"bytes"
	"crypto/md5"
	"encoding/binary"
	"os"
	"reflect"
	"strings"
	"sync/atomic"
	"time"
)
var lastCount int32
func catpath(path, name string) string {
	if path == "" {
		return name
	}
	return strings.Join([]string{path, name}, ".")
}
func indirect(v reflect.Value) reflect.Value {
loop:
	for {
		switch v.Kind() {
		case reflect.Interface, reflect.Ptr:
			v = v.Elem()
		default:
			break loop
		}
	}
	return v
}