func trailsFromHashers(items []Hasher) (trails []*SimpleProofNode, root *SimpleProofNode) {
	// Recursive impl.
	switch len(items) {
	case 0:
		return nil, nil
	case 1:
		trail := &SimpleProofNode{items[0].Hash(), nil, nil, nil}
		return []*SimpleProofNode{trail}, trail
	default:
		lefts, leftRoot := trailsFromHashers(items[:(len(items)+1)/2])
		rights, rightRoot := trailsFromHashers(items[(len(items)+1)/2:])
		rootHash := SimpleHashFromTwoHashes(leftRoot.Hash, rightRoot.Hash)
		root := &SimpleProofNode{rootHash, nil, nil, nil}
		leftRoot.Parent = root
		leftRoot.Right = rightRoot
		rightRoot.Parent = root
		rightRoot.Left = leftRoot
		return append(lefts, rights...), root
	}
}
func trailsFromHashers(items []Hasher) (trails []*SimpleProofNode, root *SimpleProofNode) {
	
	switch len(items) {
	case 0:
		return nil, nil
	case 1:
		trail := &SimpleProofNode{items[0].Hash(), nil, nil, nil}
		return []*SimpleProofNode{trail}, trail
	default:
		lefts, leftRoot := trailsFromHashers(items[:(len(items)+1)/2])
		rights, rightRoot := trailsFromHashers(items[(len(items)+1)/2:])
		rootHash := SimpleHashFromTwoHashes(leftRoot.Hash, rightRoot.Hash)
		root := &SimpleProofNode{rootHash, nil, nil, nil}
		leftRoot.Parent = root
		leftRoot.Right = rightRoot
		rightRoot.Parent = root
		rightRoot.Left = leftRoot
		return append(lefts, rights...), root
	}
}
func trailsFromHashers ( items [ ] Hasher ) ( trails [ ] * SimpleProofNode , root * SimpleProofNode ) { // Recursive impl. switch len ( items ) { case 0 : return nil , nil case 1 : trail := & SimpleProofNode { items [ 0 ] . Hash ( ) , nil , nil , nil } return [ ] * SimpleProofNode { trail } , trail default : lefts , leftRoot := trailsFromHashers ( items [ : ( len ( items ) + 1 ) / 2 ] ) rights , rightRoot := trailsFromHashers ( items [ ( len ( items ) + 1 ) / 2 : ] ) rootHash := SimpleHashFromTwoHashes ( leftRoot . Hash , rightRoot . Hash ) root := & SimpleProofNode { rootHash , nil , nil , nil } leftRoot . Parent = root leftRoot . Right = rightRoot rightRoot . Parent = root rightRoot . Left = leftRoot return append ( lefts , rights ... ) , root } }
// trails[0].Hash is the leaf hash for items[0].
// trails[i].Parent.Parent....Parent == root for all i.
trails [ 0 ] . Hash is the leaf hash for items [ 0 ] . trails [ i ] . Parent . Parent .... Parent == root for all i .