Add groupLeaves functions