isInTree method

bool isInTree(
  1. K? key
)

Returns true if key is in the tree.

Implementation

bool isInTree(K? key) {
  if (identical(root, key)) return true;

  K? cursor = key;
  while (cursor != null) {
    var parent = getParentOf(cursor);
    if (identical(parent, root)) return true;
    cursor = parent;
  }

  return false;
}