Fix tree bug

Fix errors if tree doesn't exists.