Are you sure isEmpty() and size() != 1 are equivalent here?