code: func MerkleBranch(tree Trits, siblings Trits, treeLength, treeDepth, leafIndex, leafCount uint64) (Trits, error) {
  
  	if tree == nil {
  		return nil, errors.New("Null tree")
  	}
  
  	if siblings == nil {
  		return nil, errors.New("Null sibling")
  	}
  
  	if HashTrinarySize*MerkleNodeIndex(treeDepth-1, leafIndex, treeDepth-1) >= treeLength {
  		return nil, errors.New("Leaf index out of bounds")
  	}
  
  	if treeDepth > MerkleDepth(treeLength/HashTrinarySize) {
  		return nil, errors.New("Depth out of bounds")
  	}
  
  	var siblingIndex, siteIndex uint64
  
  	siblingIndex = MerkleLeafIndex(leafIndex, leafCount)
  
  	var i int64 = 0
  	for depthIndex := treeDepth - 1; depthIndex > 0; depthIndex-- {
  
  		if (siblingIndex & 1) != 0 {
  			siblingIndex--
  		} else {
  			siblingIndex++
  		}
  
  		siteIndex = HashTrinarySize * MerkleNodeIndex(depthIndex, siblingIndex, treeDepth-1)
  		if siteIndex >= treeLength {
  			// if depth width is not even, copy a null hash
  			copy(siblings[i*HashTrinarySize:(i+1)*HashTrinarySize], merkleNullHash)
  		} else {
  			// else copy a sibling
  			copy(siblings[i*HashTrinarySize:(i+1)*HashTrinarySize], tree[siteIndex:siteIndex+HashTrinarySize])
  		}
  
  		siblingIndex >>= 1
  		i++
  	}
  	return siblings, nil
  }
docs: // MerkleBranch creates the merkle branch to generate back root from index.
  //	tree is the merkle tree - Must be allocated
  //	siblings is the siblings of the indexed node - Must be allocated
  //	treeLength is the length of the tree
  //	treeDepth is the depth of the tree
  //	leafIndex is the index of the leaf to start the branch from
  //	leafCount is the number of leaves of the tree