CPA firms do tax planning for clients like Romney. Before the end of the year (12-31-XX) they estimate the income and expenses, itemized deductions, capital gains and losses and other items to arrive at the best scenario or best outcome tax wise of decisions that can be made.
If there is a business involved they usually have a different year end than 12-31-XX just so there is time to close the business's books and if a corp or partnership to do the business's tax return to give the best outcome on the personal return.
A similar thing could be done after the fact by getting any public records such as share price and number of shares at a purchase or selling date of stocks. Salaries paid and other things.
Put those things in a tax preparation program with each years tax laws programed into it.
If Romney paid zero taxes in some years it is because his investment loses were greater than his reported taxable income.
For instance, he could have bought shares of a corporation when he owned Bain that Bain took over. You could know the share price then and the percentage control Romney had. Then Bain would drive up the corporation's share price by paying dividends with borrowed money from Bain. That increase in capital is used to pay back the loan with interest. The interest is income to Bain and is greater than the amount used to buy the original shares. Bain also earns a management fee. Then the corporation goes belly up and the share price drops below what Bain paid for it. Bain sells at a loss greater than the interest, management fee and dividends earned on the loans and dividends paid. The loss is mostly a paper loss since Bain recouped it's original purchase price.
On the tax return the loss reduces taxable income to zero. Bain keeps the interest dividends and management fees and pays no taxes on it. Bain is Romney.
My ideas here may not be what actually happened but I think I am close.