// Node returns the first subnode whose string value is equal to the given string.
// It returns nil if not found.
334284
func (g *Graph) Node(s string) *Graph {
	if g == nil || g.Out == nil {
		return nil
	}
	for _, node := range g.Out {
		if s == _string(node.This) {
			return node
		}
	}

	return nil
}
678906
func Parse(s string) (*Node, error) {
	raw := strings.TrimSpace(s)
	switch raw[0] {
	case slash:
		idx := strings.Index(raw, "<")
		if idx < 0 {
			return nil, fmt.Errorf("node.Parse: invalid format, could not find ID in %v", raw)
		}
		t, err := NewType(raw[:idx])
		if err != nil {
			return nil, fmt.Errorf("node.Parse: invalid type %q, %v", raw[:idx], err)
		}
		if raw[len(raw)-1] != '>' {
			return nil, fmt.Errorf("node.Parse: pretty printing should finish with '>' in %q", raw)
		}
		id, err := NewID(raw[idx+1 : len(raw)-1])
		if err != nil {
			return nil, fmt.Errorf("node.Parse: invalid ID in %q, %v", raw, err)
		}
		return NewNode(t, id), nil
	case underscore:
		id, err := NewID(raw[2:len(raw)])
		if err != nil {
			return nil, fmt.Errorf("node.Parse: invalid ID in %q, %v", raw, err)
		}
		t, _ := NewType("/_")
		return NewNode(t, id), nil
	default:
		return nil, fmt.Errorf("node.Parse: node representation should start with '/' or '_' in %v", raw)
	}
}
326930
func (node *Expression) String() string {
	return fmt.Sprintf("Expr{Path:%s, Pos:%d}", node.Path, node.Loc.Pos)
}
586342
func (t *FromNode) String() string {
	keys := make([]string, len(t.Imports))
	i := 0
	for orig := range t.Imports {
		keys[i] = orig
		i++
	}
	sort.Strings(keys)
	res := make([]string, len(t.Imports))
	for i, orig := range keys {
		if orig == t.Imports[orig] {
			res[i] = orig
		} else {
			res[i] = orig + " as " + t.Imports[orig]
		}
	}
	return fmt.Sprintf("From %s import %s", t.Tpl, strings.Join(res, ", "))
}
593776
func (nDB *NetworkDB) findNode(nodeName string) (*node, nodeState, map[string]*node) {
	for i, nodes := range []map[string]*node{
		nDB.nodes,
		nDB.leftNodes,
		nDB.failedNodes,
	} {
		if n, ok := nodes[nodeName]; ok {
			return n, nodeState(i), nodes
		}
	}
	return nil, nodeNotFound, nil
}
1100076
func (t *ForNode) String() string {
	return fmt.Sprintf("For(%s, %s in %s: %s else %s)", t.Key, t.Val, t.X, t.Body, t.Else)
}
452278
func (group *NodeGroup) GetNode(i int) Node {
	group.mux.RLock()
	defer group.mux.RUnlock()

	if i < 0 || group == nil || len(group.nodes) <= i {
		return Node{}
	}
	return group.nodes[i]
}
730849
func Nodes(sel interface{}, nodes *[]*cdp.Node, opts ...QueryOption) Action {
	if nodes == nil {
		panic("nodes cannot be nil")
	}

	return QueryAfter(sel, func(ctx context.Context, n ...*cdp.Node) error {
		*nodes = n
		return nil
	}, opts...)
}
838016
func nextNode(it iterator.Iterator) *Node {
	for end := false; !end; end = !it.Next() {
		id, field := splitKey(it.Key())
		if field != nodeDBDiscoverRoot {
			continue
		}
		var n Node
		if err := rlp.DecodeBytes(it.Value(), &n); err != nil {
			log.Warn(fmt.Sprintf("invalid node %x: %v", id, err))
			continue
		}
		return &n
	}
	return nil
}
16337
func (b *Bucket) Nodes() []Node {
	b.RLock()
	defer b.RUnlock()
	ret := *(*[]Node)(b.nodeList)
	return ret
}
1324161
func (l *List) Find(v *Node) (e *Element) {
	if l.len == 0 {
		return nil
	}
	for e = l.Front(); e != nil && e.Value != v; e = e.Next() {
	}
	return
}
790546
func (n *Node) Tree(path string, depth int) []string {
	if path == "" && depth == -1 {
		return n.tree
	}

	var out []string
	for _, t := range n.tree {
		if !strings.HasPrefix(t, path) {
			continue
		}

		sub := strings.TrimLeft(t[len(path):], "/")
		if sub == "" {
			continue
		}

		if depth < 0 {
			out = append(out, sub)
			continue
		}

		parts := strings.Split(sub, "/")
		if len(parts) <= depth {
			out = append(out, sub)
		}
	}
	return out
}
330411
func (c *Client) GetNode(nodeID string) (*p2p.NodeInfo, error) {
	node := &p2p.NodeInfo{}
	return node, c.Get(fmt.Sprintf("/nodes/%s", nodeID), node)
}
293131
func (n *node) String() string {
	out := fmt.Sprintf("[%v", n.content)
	if len(n.children) > 0 {
		out += " "
		for _, child := range n.children {
			out += child.String()
		}
	}
	out += "]"
	return out
}
577712
func find(label string, lo, hi uint32) uint32 {
	for lo < hi {
		mid := lo + (hi-lo)/2
		s := nodeLabel(mid)
		if s < label {
			lo = mid + 1
		} else if s == label {
			return mid
		} else {
			hi = mid
		}
	}
	return notFound
}
1190004
func (node *PathExpression) String() string {
	return fmt.Sprintf("Path{Original:'%s', Pos:%d}", node.Original, node.Loc.Pos)
}
355095
func GetNode(uuid string) (Node, error) {

	url := ""
	if string(uuid[0]) == "/" {
		url = uuid[8:]
	} else {
		url = "node/" + uuid + "/"
	}

	request := "GET"
	body := []byte(`{}`)
	var response Node

	data, err := TutumCall(url, request, body)
	if err != nil {
		return response, err
	}

	err = json.Unmarshal(data, &response)
	if err != nil {
		return response, err
	}

	return response, nil
}