def _get_transaction_stack_depth(transaction):
    """ build history stack by transaction depth """
    depth = 0
    current = transaction
    while current:
        depth += 1
        current = transaction.parent
    return depth
