Tree-datastructure implementations (imported from temporary repository)