isInTree method

bool isInTree(
  1. K? key
)

Returns true if key is in the tree.

Implementation

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

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