docs: private Payment toPayment(final PaymentModelDao curPaymentModelDao, final Collection<PaymentTransactionModelDao> allTransactionsModelDao, @Nullable final Iterable<PaymentTransactionInfoPlugin> pluginTransactions, final boolean withAttempts, final InternalTenantContext internalTenantContext) {
          // Need to filter for optimized codepaths looking up by account_record_id
          final Collection<PaymentTransactionModelDao> transactionsModelDao = new LinkedList<PaymentTransactionModelDao>(Collections2.filter(allTransactionsModelDao, new Predicate<PaymentTransactionModelDao>() {
              @Override
              public boolean apply(final PaymentTransactionModelDao curPaymentTransactionModelDao) {
                  return curPaymentTransactionModelDao.getPaymentId().equals(curPaymentModelDao.getId());
              }
          }));
  
          if (pluginTransactions != null) {
              invokeJanitor(curPaymentModelDao, transactionsModelDao, pluginTransactions, internalTenantContext);
          }
  
          final Collection<PaymentTransaction> transactions = new LinkedList<PaymentTransaction>();
          for (final PaymentTransactionModelDao newPaymentTransactionModelDao : transactionsModelDao) {
              final PaymentTransactionInfoPlugin paymentTransactionInfoPlugin = findPaymentTransactionInfoPlugin(newPaymentTransactionModelDao, pluginTransactions);
              final PaymentTransaction transaction = new DefaultPaymentTransaction(newPaymentTransactionModelDao.getId(),
                                                                                   newPaymentTransactionModelDao.getAttemptId(),
                                                                                   newPaymentTransactionModelDao.getTransactionExternalKey(),
                                                                                   newPaymentTransactionModelDao.getCreatedDate(),
                                                                                   newPaymentTransactionModelDao.getUpdatedDate(),
                                                                                   newPaymentTransactionModelDao.getPaymentId(),
                                                                                   newPaymentTransactionModelDao.getTransactionType(),
                                                                                   newPaymentTransactionModelDao.getEffectiveDate(),
                                                                                   newPaymentTransactionModelDao.getTransactionStatus(),
                                                                                   newPaymentTransactionModelDao.getAmount(),
                                                                                   newPaymentTransactionModelDao.getCurrency(),
                                                                                   newPaymentTransactionModelDao.getProcessedAmount(),
                                                                                   newPaymentTransactionModelDao.getProcessedCurrency(),
                                                                                   newPaymentTransactionModelDao.getGatewayErrorCode(),
                                                                                   newPaymentTransactionModelDao.getGatewayErrorMsg(),
                                                                                   paymentTransactionInfoPlugin);
              transactions.add(transaction);
          }
  
          final Ordering<PaymentTransaction> perPaymentTransactionOrdering = Ordering.<PaymentTransaction>from(new Comparator<PaymentTransaction>() {
              @Override
              public int compare(final PaymentTransaction o1, final PaymentTransaction o2) {
                  return o1.getEffectiveDate().compareTo(o2.getEffectiveDate());
              }
          });
          final List<PaymentTransaction> sortedTransactions = perPaymentTransactionOrdering.immutableSortedCopy(transactions);
          return new DefaultPayment(curPaymentModelDao.getId(),
                                    curPaymentModelDao.getCreatedDate(),
                                    curPaymentModelDao.getUpdatedDate(),
                                    curPaymentModelDao.getAccountId(),
                                    curPaymentModelDao.getPaymentMethodId(),
                                    curPaymentModelDao.getPaymentNumber(),
                                    curPaymentModelDao.getExternalKey(),
                                    sortedTransactions,
                                    (withAttempts && !sortedTransactions.isEmpty()) ?
                                    getPaymentAttempts(paymentDao.getPaymentAttempts(curPaymentModelDao.getExternalKey(), internalTenantContext),
                                                       internalTenantContext) : null
          );
      }