midpoint function

Tree manipulation