Cleanup node hierarchy