Added logic for determining weakly connected groups of Heaproots and changed traverse...