a generic implementation of a directed tree