fix: broken commutativity in join distribution deduction
Join node deduces the distribution of its output tuple based on the output tuples of its left and right children. The logic of deduction was broken: if we swap the children the distribution changed. So, current commit rewrites join distribution deduction.
Also we refactor some parts of the set_distribution() function. Its code style is still bad, but now it is not so horrible as before.