// hasKeyPath - if the map 'key' exists append it to KeyPath.path and increment KeyPath.depth
// This is really just a breadcrumber that saves all trails that hit the prescribed 'key'.
230
func hasKeyPath(crumb string, iv interface{}, key string, basket *map[string]bool) {
	switch iv.(type) {
	case map[string]interface{}:
		vv := iv.(map[string]interface{})
		if _, ok := vv[key]; ok {
			if crumb == "" {
				crumb = key
			} else {
				crumb += "." + key
			}
			// *basket = append(*basket, crumb)
			(*basket)[crumb] = true
		}
		// walk on down the path, key could occur again at deeper node
		for k, v := range vv {
			// create a new breadcrumb, add the one we're at to the crumb-trail
			var nbc string
			if crumb == "" {
				nbc = k
			} else {
				nbc = crumb + "." + k
			}
			hasKeyPath(nbc, v, key, basket)
		}
	case []interface{}:
		// crumb-trail doesn't change, pass it on
		for _, v := range iv.([]interface{}) {
			hasKeyPath(crumb, v, key, basket)
		}
	}
}
207891
func (tr *Transaction) Has(key []byte, ro *opt.ReadOptions) (bool, error) {
	tr.lk.RLock()
	defer tr.lk.RUnlock()
	if tr.closed {
		return false, errTransactionDone
	}
	return tr.db.has(tr.mem.DB, tr.tables, key, tr.seq, ro)
}
1300205
func (s *GlobalStore) HasKey(addr common.Address, key []byte) (yes bool) {
	s.mu.RLock()
	defer s.mu.RUnlock()

	_, yes = s.nodeKeyIndex(addr, key)
	return yes
}
842913
func HasKeyword(keyvals []KeyVal, keyword Keyword) []KeyVal {
	kvs := []KeyVal{}
	for i := range keyvals {
		if keyvals[i].Keyword().Prefix() == keyword.Prefix() {
			kvs = append(kvs, keyvals[i])
		}
	}
	return kvs
}
1272036
func (params Params) Has(key string) bool {
	_, ok := params[key]
	return ok
}
113135
func HasTrailingPathSeparator(path string) bool {
	return len(path) > 0 && os.IsPathSeparator(path[len(path)-1])
}
231366
func (m *SyncMap) Has(key string) bool {
	_, ok := m.Get(key)
	return ok
}
1087263
func (k *key) Path() path.Path {
	return path.New(ipfspath.Join([]string{"/ipns", k.peerID.Pretty()}))
}
170140
func (t *Tree) DeletePath(keys []string) error {
	keyLen := len(keys)
	if keyLen == 1 {
		delete(t.values, keys[0])
		return nil
	}
	tree := t.GetPath(keys[:keyLen-1])
	item := keys[keyLen-1]
	switch node := tree.(type) {
	case *Tree:
		delete(node.values, item)
		return nil
	}
	return errors.New("no such key to delete")
}
271024
func (k Key) Path() Key {
	s := k.Parent().string + "/" + NamespaceType(k.BaseNamespace())
	return NewKey(s)
}
211696
func (t *Mutable) Has(key []byte) bool {
	if node, _ := t.get(key); node != nil {
		return true
	}
	return false
}
668909
func hasPathPrefix(s, prefix string) bool {
	switch {
	default:
		return false
	case len(s) == len(prefix):
		return s == prefix
	case len(s) > len(prefix):
		if prefix != "" && prefix[len(prefix)-1] == '/' {
			return strings.HasPrefix(s, prefix)
		}
		return s[len(prefix)] == '/' && s[:len(prefix)] == prefix
	}
}
1152199
func hasBadPathComponent(path string) bool {
	path = strings.TrimSpace(path)
	for _, p := range strings.Split(path, slashSeparator) {
		switch strings.TrimSpace(p) {
		case dotdotComponent:
			return true
		case dotComponent:
			return true
		}
	}
	return false
}
952784
func PathsForKey(m map[string]interface{}, key string) []string {
	breadbasket := make(map[string]bool,0)
	breadcrumb := ""

	hasKeyPath(breadcrumb, m, key, &breadbasket)
	if len(breadbasket) == 0 {
		return nil
	}

	// unpack map keys to return
	res := make([]string,len(breadbasket))
	var i int
	for k,_ := range breadbasket {
		res[i] = k
		i++
	}

	return res
}
661016
func (it *Optional) NextPath(ctx context.Context) bool {
	if it.lastCheck {
		ok := it.subIt.NextPath(ctx)
		if !ok {
			it.err = it.subIt.Err()
		}
		return ok
	}
	return false
}
418226
func kvPaths(b *backend) []*framework.Path {
	return []*framework.Path{
		&framework.Path{
			Pattern: "kv/?",
			Callbacks: map[logical.Operation]framework.OperationFunc{
				logical.ListOperation: b.pathKVList,
			},
		},
		&framework.Path{
			Pattern: "kv/" + framework.GenericNameRegex("key"),
			Fields: map[string]*framework.FieldSchema{
				"key":     &framework.FieldSchema{Type: framework.TypeString},
				"value":   &framework.FieldSchema{Type: framework.TypeString},
				"version": &framework.FieldSchema{Type: framework.TypeInt},
			},
			ExistenceCheck: b.pathExistenceCheck,
			Callbacks: map[logical.Operation]framework.OperationFunc{
				logical.ReadOperation:   b.pathKVRead,
				logical.CreateOperation: b.pathKVCreateUpdate,
				logical.UpdateOperation: b.pathKVCreateUpdate,
				logical.DeleteOperation: b.pathKVDelete,
			},
		},
	}
}
1156466
func isSamePath(path1, path2 []*channeldb.ChannelEdgePolicy) bool {
	if len(path1) != len(path2) {
		return false
	}

	for i := 0; i < len(path1); i++ {
		if path1[i].ChannelID != path2[i].ChannelID {
			return false
		}
	}

	return true
}