The second loop is unreachable: the first loop returns as soon as it finds an existing candidate. Collapse to a single iterator chain.