added utility functions to be able to work with trees of distributions