move common binary tree functions to a different file for reuse