code: def compute_merkleproof_for(merkletree: 'MerkleTreeState', element: Keccak256) -> List[Keccak256]:
      
      idx = merkletree.layers[LEAVES].index(element)
  
      proof = []
      for layer in merkletree.layers:
          if idx % 2:
              pair = idx - 1
          else:
              pair = idx + 1
  
          # with an odd number of elements the rightmost one does not have a pair.
          if pair < len(layer):
              proof.append(layer[pair])
  
          # the tree is binary and balanced
          idx = idx // 2
  
      return proof
docs: Containment proof for element.
  
      The proof contains only the entries that are sufficient to recompute the
      merkleroot, from the leaf `element` up to `root`.
  
      Raises:
          IndexError: If the element is not part of the merkletree.