def METHOD_NAME(loan_pid, status=None):
    """Return last fee for loan.
    :param loan_pid: the loan pid to search.
    :param status: (optional) the status of transaction.
    :return: return last transaction transaction matching criteria.
    """
    query = PatronTransactionsSearch() \
        .filter('term', loan__pid=loan_pid)
    if status:
        query = query.filter('term', status=status)
    results = query \
        .sort({'creation_date': {'order': 'desc'}}) \
        .source('pid').scan()
    try:
        pid = next(results).pid
        return PatronTransaction.get_record_by_pid(pid)
    except StopIteration:
        return None