tree including binary tree check algorithm