getParentKey method
Get 1st parent key of child;
Implementation
K? getParentKey(K? child, {bool includePurgedEntries = false}) {
if (child == null || identical(child, root)) return null;
if (includePurgedEntries) {
final purged = _purged;
var cursor = getParentOf(child);
while (cursor != null) {
if (_map.containsKey(cursor) ||
(purged?.containsKey(cursor) ?? false)) {
return cursor;
}
cursor = getParentOf(cursor);
}
} else {
var cursor = getParentOf(child);
while (cursor != null) {
if (_map.containsKey(cursor)) return cursor;
cursor = getParentOf(cursor);
}
}
if (isChildOf(root, child, false)) {
return root;
}
return null;
}