How to do binary search on a path in a binary heap
Note that a path from the root to $heap[i]$ is in the sorted order. Moreover, the path length is $O(\log n)$. You just need to do binary search on this path. For that, you need to access the $i^{th}$ ancestor of any node in the heap in $O(1)$ time. Assuming $1$ based indexing, the $1^{st}$ ancestor of $heap[i]$ is located at $\lfloor \frac{i}{2} \rfloor$ location in the array. The $2^{nd}$ ancestor of $heap[i]$ is located at $\lfloor \frac{i}{4} \rfloor$ location, and so on. Using it you can easily perform binary search on the path from root to $heap[i]$ in $O(\log \log n)$ time.
Pseudocode:
Assume that we have a min heap. Initialize, start = $1$ and end =  $h = \lfloor \log(i) \rfloor$
BinarySerach (start, end)

mid = (start + end)/2
index of mid = i/(2^(h- mid)) //(h-mid)^th ancestor of i

if (end-start = 1)
    if (heap[index of mid] == x) return &quot;YES&quot;; otherwise &quot;NO&quot;.

if (heap[index of mid] &gt;= x)
   return BinarySearch (start, mid)
else  
   return BinarySearch (mid+1,end)