public void SetNewHead(MiniMaxNode newHead) throws Exception { MiniMaxNode node = Find(newHead); if (node == null) { throw new Exception("No such node: " + newHead.toString()); } else { this.head = node; this.head.parent = null; // Rather than figuring out which empty parents are no long valid, // Just clear the list and start over. The cost is minimal. emptyParents.clear(); emptyParents.addAll(FindEmptyParents()); } }