e.g
Here Function heapifyUp is getting called twice
(I Need a single call).
return self.heapifyUp(parentIndex) if self.heapifyUp(parentIndex) != -1 else realIndex
Well, it's called twice because
you call it twice... :-)
To call it once, assign the result to a variable:
res = self.heapifyUp(parentIndex)
return res if res != -1 else realIndex
(BTW, you don't need the ; at the end)