Check if an element exists in a binary tree