completing a tree problem (clustering)