PMO-2710 Only try to remove nodes from tree if they are in it (part 2)