Primitive functions and traversals for binary tree