:type root: TreeNode
    :rtype: bool
501481
def is_bst(root):
    

    stack = []
    pre = None
    
    while root or stack:
        while root:
            stack.append(root)
            root = root.left
        root = stack.pop()
        if pre and root.val <= pre.val:
            return False
        pre = root
        root = root.right

    return True
779693
def _root(self):
        
        _n = self
        while _n.parent:
            _n = _n.parent
        return _n
691058
def xml_to_root(xml: Union[str, IO]) -> ElementTree.Element:
    
    if isinstance(xml, str):
        if '<' in xml:
            return ElementTree.fromstring(xml)
        else:
            with open(xml) as fh:
                xml_to_root(fh)
    tree = ElementTree.parse(xml)
    return tree.getroot()
656892
def _get_tree_properties(root):
    
    is_descending = True
    is_ascending = True
    min_node_value = root.value
    max_node_value = root.value
    size = 0
    leaf_count = 0
    min_leaf_depth = 0
    max_leaf_depth = -1
    is_strict = True
    is_complete = True
    current_nodes = [root]
    non_full_node_seen = False

    while len(current_nodes) > 0:
        max_leaf_depth += 1
        next_nodes = []

        for node in current_nodes:
            size += 1
            value = node.value
            min_node_value = min(value, min_node_value)
            max_node_value = max(value, max_node_value)

            # Node is a leaf.
            if node.left is None and node.right is None:
                if min_leaf_depth == 0:
                    min_leaf_depth = max_leaf_depth
                leaf_count += 1

            if node.left is not None:
                if node.left.value > value:
                    is_descending = False
                elif node.left.value < value:
                    is_ascending = False
                next_nodes.append(node.left)
                is_complete = not non_full_node_seen
            else:
                non_full_node_seen = True

            if node.right is not None:
                if node.right.value > value:
                    is_descending = False
                elif node.right.value < value:
                    is_ascending = False
                next_nodes.append(node.right)
                is_complete = not non_full_node_seen
            else:
                non_full_node_seen = True

            # If we see a node with only one child, it is not strict
            is_strict &= (node.left is None) == (node.right is None)

        current_nodes = next_nodes

    return {
        'height': max_leaf_depth,
        'size': size,
        'is_max_heap': is_complete and is_descending,
        'is_min_heap': is_complete and is_ascending,
        'is_perfect': leaf_count == 2 ** max_leaf_depth,
        'is_strict': is_strict,
        'is_complete': is_complete,
        'leaf_count': leaf_count,
        'min_node_value': min_node_value,
        'max_node_value': max_node_value,
        'min_leaf_depth': min_leaf_depth,
        'max_leaf_depth': max_leaf_depth,
    }
953107
def CurrentNode(self):
        
        ret = libxml2mod.xmlTextReaderCurrentNode(self._o)
        if ret is None:raise treeError('xmlTextReaderCurrentNode() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
447031
function isNodeInRoot(node, root) {
    node = ReactDOM.findDOMNode(node), root = ReactDOM.findDOMNode(root);
    return _isNodeInRoot(node, root);
}
915378
def root(self):
        
        node = self
        while node.package is not None:
            node = node.package
        return node
127277
def visit_root(node, &operator)
      clear
      # Exclude cycles if the prune cycles flag is set. 
      @exclude.merge!(cyclic_nodes(node)) if @prune_cycle_flag 
      # Visit the root node.
      result = visit_recursive(node, &operator)
      # Reset the exclusions if the prune cycles flag is set.
      @exclude.clear if @prune_cycle_flag 
      result
    end
839878
def uproot(tree):
        
        uprooted = tree.copy()
        uprooted.parent = None
        for child in tree.all_children():
            uprooted.add_general_child(child)
        return uprooted
864385
def root(self):
        
        if self.is_root:
            return self
        return self.adapter.wrap_node(
            self.adapter.impl_root_element, self.adapter.impl_document,
            self.adapter)
404506
def to_tree(self):
        
        tree = TreeLibTree()
        for node in self:
            tree.create_node(node, node.node_id, parent=node.parent)
        return tree
717350
def t(root, children=None, debug=False, root_id=None):
    ""
    if isinstance(root, Tree):
        if children is None:
            return root
        return root.__class__(root, children, root_id)

    elif isinstance(root, basestring):
        root = debug_root_label(root, debug, root_id)

        # Beware: (DGParented)Tree is a subclass of list!
        if isinstance(children, Tree):
            child_trees = [children]

        elif isinstance(children, list):
            child_trees = []
            for child in children:
                if isinstance(child, Tree):
                    child_trees.append(child)
                elif isinstance(child, list):
                    child_trees.extend(child)
                elif isinstance(child, tuple):
                    child_trees.append(t(*child))
                elif isinstance(child, basestring):
                    child_trees.append(child)
                else:
                    raise NotImplementedError

        elif isinstance(children, basestring):
            # this tree does only have one child, a leaf node
            # TODO: this is a workaround for the following problem:
            # Tree('foo', [Tree('bar', [])]) != Tree('foo', ['bar'])
            child_trees = [Tree(children, [])]

        else:
            # this tree only consists of one leaf node
            assert children is None
            child_trees = []

        return DGParentedTree(root, child_trees, root_id)

    else:
        raise NotImplementedError
771215
def _tree_line(self, no_type: bool = False) -> str:
        """"""
        keys = (" [" + " ".join([k[0] for k in self.keys]) + "]"
                if self.keys else "")
        return super()._tree_line() + keys
1205940
function coerceRoot(root) {
  var coerced = root.substring().trim();
  var len = coerced.length;
  if (len > 0 && coerced[len - 1] !== '/') {
    coerced = coerced + '/';
  }
  return coerced;
}
94055
def visit_root(node)
      @enabled = matcher.match(File.basename(node.file)) ? true : false
    end
265351
private boolean mkdir(boolean parent)
  {
    synchronized (_rootNode) {
      String fullPath = getFullPath();

      int head = 0;
      Node node = this._rootNode;

      while (node != null && head < fullPath.length()) {
        int tail = fullPath.indexOf('/', head);
        String name;

        if (tail == head) {
          head = tail + 1;
          continue;
        }
        if (tail == -1) {
          name = fullPath.substring(head);
          if (node.lookup(name) != null)
            return false;
          node.createDir(name);
          return true;
        }

        name = fullPath.substring(head, tail);
        Node next = node.lookup(name);

        if (next == null && parent)
          next = node.createDir(name);

        if (next == null || next.type != next.DIR)
          return false;

        node = next;
        head = tail + 1;
      }

      return false;
    }
  }
794614
def root_parent(self, category=None):
        
        return next(filter(lambda c: c.is_root, self.hierarchy()))