add classes hierarchy of tree elements