Motivated by T6959, several utilities are generalized (tree-union; reference tree cache i/o) and some minor internal changes added (mutability of config and reference trees). These will be added independently of T6959, as needed by T6946 and other development.