Works! Uses a stack instead of recursion to check for dead groups. (very ugly function though