clean up tree pointer casting