findParentCached function

FNode? findParentCached(
  1. FluentDocument document,
  2. FNode node
)

O(1) per step parent lookup using the document's cached parent map. Returns the direct parent FNode of node, or null if node is the root.

Implementation

FNode? findParentCached(FluentDocument document, FNode node) {
  final parentId = document.findParentCached(node.id);
  if (parentId == null) return null;
  return document.nodeById(parentId);
}