trace method
Traces the path from a node back to its root
Implementation
Future<List<Node>> trace(String nodeId) async {
final path = <Node>[];
String? currentId = nodeId;
while (currentId != null) {
try {
final node = await _repository.get(currentId);
node.validate();
path.add(node);
currentId = node.previous;
} catch (e) {
if (e is RepositoryException &&
e.code == RepositoryErrorCode.notFound) {
break;
}
rethrow;
}
}
return path;
}