diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/MfdTrees.java b/src/main/java/gov/usgs/earthquake/nshmp/model/MfdTrees.java index c67635db24cda4d3c276460ce785498c05f38ca5..a27d8583a9f62dbdca187842d73bb90f037a1561 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/MfdTrees.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/MfdTrees.java @@ -248,6 +248,16 @@ class MfdTrees { return pathTree.build(); } + /* Create an exact copy of the supplied tree. */ + static <T> LogicTree<T> copy(LogicTree<T> tree) { + LogicTree.Builder<T> copy = LogicTree.builder(tree.name()); + tree.forEach(branch -> copy.addBranch( + branch.id(), + branch.value(), + branch.weight())); + return copy.build(); + } + /* * Transpose a list of logic trees to a logic tree of immutable lists. * Supplied logic trees are assumed to have same branch names and IDs.