This creates a single method we can rely on to check for the uniqueness
of a segment name and refactors places where we had duplicate code to
use the new method.
[MAILPOET-3998]
We needed to get number of rows which meet the condition.
I couldn't use DQL since it doesn't allow a subquery in FROM
so I rewrote the query using DBAL level query builder.
[MAILPOET-3922]