/*
* If first and second fractions' denominators are products, find fracion with
* common denominator.
*/
private Fraction getSumWithProductDenominator(Fraction first, Fraction second) {
TensorSortedContent firstContent = ((Product) first.getDenominator()).getContent();
TensorSortedContent secondContent = ((Product) second.getDenominator()).getContent();
Tensor firstMultiplyed = first.getNumerator();
Tensor secondMultiplyed = second.getNumerator();
List<Tensor> firstProduct = new ArrayList<>();
List<Tensor> secondProduct = new ArrayList<>();
firstProduct.add(secondMultiplyed);
secondProduct.add(firstMultiplyed);
Product denominator = new Product();
int j = 0;
boolean firstIsFinish = false;
for (int i = 0; i < secondContent.size(); i++) {
if (firstIsFinish) {
secondProduct.add(secondContent.get(i));
denominator.add(secondContent.get(i));
continue;
}
if (secondContent.get(i).hashCode() < firstContent.get(j).hashCode()) {
secondProduct.add(secondContent.get(i));
denominator.add(secondContent.get(i));
continue;
} else if (secondContent.get(i).hashCode() > firstContent.get(j).hashCode()) {
firstProduct.add(firstContent.get(j));
denominator.add(firstContent.get(j));
j++;
if (j == firstContent.size())
firstIsFinish = true;
i--;
continue;
} else if (secondContent.get(i).hashCode() == firstContent.get(j).hashCode())
while (secondContent.get(i).hashCode() == firstContent.get(j).hashCode() && j < firstContent.size())
if (TTest.testParity(secondContent.get(i), firstContent.get(j))) {
denominator.add(firstContent.get(j));
j++;
if (j == firstContent.size())
firstIsFinish = true;
break;