private @Nullable T validateAndGetRepository(@Nullable Repository repository) {
    if (repository == null ||
        !myVcsKey.equals(repository.getVcs().getKeyInstanceMethod()) ||
        !repository.getRoot().isValid()) {
      return null;
    }

    //noinspection unchecked
    return (T)repository;
  }
private @Nullable T validateAndGetRepository(@Nullable Repository repository)