graph assembles list of leaves if tree