typecheck tree using context