Major work on the TreeElement class (code & tests)