+ /**
+ * Rebuild the latestBranch "cache" object by reading the nodes from disk
+ * (When we are opening an existing file on disk and want to append to it,
+ * for example).
+ *
+ * @param rootNodeSeqNb
+ * The sequence number of the root node, so we know where to
+ * start
+ * @throws ClosedChannelException
+ */
+ private List<CoreNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
+ HTNode nextChildNode;
+
+ List<CoreNode> list = new ArrayList<>();
+
+ nextChildNode = treeIO.readNode(rootNodeSeqNb);
+ list.add((CoreNode) nextChildNode);
+ while (list.get(list.size() - 1).getNbChildren() > 0) {
+ nextChildNode = treeIO.readNode(list.get(list.size() - 1).getLatestChild());
+ list.add((CoreNode) nextChildNode);
+ }
+ return Collections.synchronizedList(list);
+ }
+