Moved tree logic to TreeControl