P3: binary tree implementation