func (set *Set) clone() *Set {
	var newkids []*Set
	if set.kids != nil {
		newkids = make([]*Set, ARITY)
		copy(newkids, set.kids)
	}
	cs := &Set{
		val:  set.val,
		full: set.full,
		kids: newkids,
		size: set.size,
	}
	return cs
}
Returns a copy of this set node, including allocating and copying the kids
slice.
package seq
import (
	"bytes"
	"fmt"
	"hash/crc32"
	"reflect"
)
type Setable interface {
	Hash(uint32) uint32
	Equal(interface{}) bool
}
func hash(v interface{}, i uint32) uint32 {
	switch vt := v.(type) {
	case Setable:
		return vt.Hash(i) % ARITY
	case uint32:
		return (i + vt) % ARITY
	case uint:
		return hash(uint32(vt), i)
	case uint8:
		return hash(uint32(vt), i)
	case uint64:
		return hash(uint32(vt), i)
	case int:
		return hash(uint32(vt), i)
	case int8:
		return hash(uint32(vt), i)
	case int16:
		return hash(uint32(vt), i)
	case int32:
		return hash(uint32(vt), i)
	case int64:
		return hash(uint32(vt), i)
	case float32:
		return hash(uint32(vt), i)
	case float64:
		return hash(uint32(vt), i)
	case string:
		return hash([]byte(vt), i)
	case []rune:
		return hash([]byte(string(vt)), i)
	case []byte:
		return crc32.ChecksumIEEE(vt) % ARITY
	default:
		err := fmt.Sprintf("%s not hashable", reflect.TypeOf(v))
		panic(err)
	}
}
func equalDirected(v1, v2 interface{}) bool {
	if v1t, ok := v1.(Setable); ok {
		return v1t.Equal(v2)
	} else if v1t, ok := v1.(Comparable); ok {
		if v2t, ok := v2.(Seq); ok {
			return v1t.Equal(v2t)
		}
	}
	return false
}
func equal(v1, v2 interface{}) bool {
	if equalDirected(v1, v2) {
		return true
	} else if equalDirected(v2, v1) {
		return true
	} else if v1t, ok := v1.([]byte); ok {
		if v2t, ok := v2.([]byte); ok {
			return bytes.Equal(v1t, v2t)
		}
		return false
	}
	return v1 == v2
}
const ARITY = 32
type Set struct {
	val interface{}
	full bool
	kids []*Set
	size uint64
}
func NewSet(vals ...interface{}) *Set {
	if len(vals) == 0 {
		return nil
	}
	set := new(Set)
	for i := range vals {
		set.setValDirty(vals[i], 0)
	}
	set.size = uint64(len(vals))
	return set
}
func (set *Set) Hash(i uint32) uint32 {
	sum := uint32(0)
	s := Seq(set)
	var el interface{}
	var ok bool
	for {
		if el, s, ok = s.FirstRest(); !ok {
			return sum
		}
		sum += hash(el, i)
	}
}
func (set *Set) Equal(v interface{}) bool {
	set2, ok := v.(*Set)
	if !ok {
		return false
	}
	if set.Size() != set2.Size() {
		return false
	}
	sset := Seq(set)
	var el interface{}
	for {
		el, sset, ok = sset.FirstRest()
		if !ok {
			return true
		} else if _, ok = set2.GetVal(el); !ok {
			return false
		}
	}
}
func (set *Set) shallowTrySetOrInit(val interface{}) (bool, bool) {
	if !set.full {
		set.val = val
		set.full = true
		return true, false
	} else if equal(set.val, val) {
		set.val = val
		set.full = true
		return true, true
	} else if set.kids == nil {
		set.kids = make([]*Set, ARITY)
	}
	return false, false
}
func (set *Set) setValDirty(val interface{}, i uint32) {
	if ok, _ := set.shallowTrySetOrInit(val); ok {
		return
	}
	h := hash(val, i)
	if kid := set.kids[h]; kid != nil {
		kid.setValDirty(val, i+1)
	} else {
		set.kids[h] = NewSet(val)
	}
}