simplifying and refactoring the distribution tree implementation, fixes problems in #3475 #2562 #3893
simplifying and refactoring the distribution tree implementation, fixes problems in #3475 #2562 #3893