// Search to find the key in the binarySearchTree,
// return payload if found, nil if not found
// NOTE that if there're multiple nodes with same key, will only return the first one
Search to find the key in the binarySearchTree,
return payload if found, nil if not found
NOTE that if there're multiple nodes with same key, will only return the first one
// Search to find the key in the binarySearchTree // return payload if found nil if not found // NOTE that if there ' re multiple nodes with same key will only return the first one
func (b BinarySearchTree) Search(key int) (interface{}, error) {
	node := b.searchNode(key)
	if node == nil {
		return nil, fmt.Errorf("key %v does not exist", key)
	}
	return node.payload, nil
}
func ( b BinarySearchTree ) Search ( key int ) ( interface { } , error ) { node := b . searchNode ( key ) if node == nil { return nil , fmt . Errorf ( " " , key ) } return node . payload , nil }
Search to find the key in the binarySearchTree,
return payload if found, nil if not found
NOTE that if there're multiple nodes with same key, will only return the first one
Search to find the key in the binarySearchTree return payload if found nil if not found NOTE that if there ' re multiple nodes with same key will only return the first one