Parse the whole tree and point ``root_branchset`` attribute
        to the tree's root.
488922
def parse_tree(self, tree_node, validate):
        
        self.info = collect_info(self.filename)
        self.source_ids = collections.defaultdict(list)
        t0 = time.time()
        for depth, branchinglevel_node in enumerate(tree_node.nodes):
            self.parse_branchinglevel(branchinglevel_node, depth, validate)
        dt = time.time() - t0
        if validate:
            bname = os.path.basename(self.filename)
            logging.info('Validated %s in %.2f seconds', bname, dt)
751705
ParseTree toParseTree() {
    List<ParseTree> children = new ArrayList<ParseTree>();
    for (TreeNode child = latestChild; child != null; child = child.previous) {
      children.add(child.toParseTree());
    }
    Collections.reverse(children);
    return new ParseTree(name, beginIndex, endIndex, result, children);
  }
210669
def parse(self):
        """"""
        result = nodes.Template(self.subparse(), lineno=1)
        result.set_environment(self.environment)
        return result
1284810
def as_tree(self):
        ""
        if self._nodes is None:
            return [self]
        ret = [self]
        for node in self._nodes:
            ret.append(node.as_tree())
        return ret
735190
def tree(self):
        
        tree = self.get('tree')
        if isinstance(tree, stringtypes):
            tree = SExpr.parse(tree).data
        elif tree is None:
            drv = self.get('derivation')
            if isinstance(drv, dict) and 'label' in drv:
                def _extract_tree(d):
                    t = [d.get('label', '')]
                    if 'tokens' in d:
                        t.append([d.get('form', '')])
                    else:
                        for dtr in d.get('daughters', []):
                            t.append(_extract_tree(dtr))
                    return t
                tree = _extract_tree(drv)
        return tree
573570
def parse_root
      s0 = @current_pos
      s1 = []
      s2 = parse_header
      while s2 != :failed
        s1 << s2
        s2 = parse_header
      end
      if s1 != :failed
        s2 = parse_initialboard
        s2 = nil if s2 == :failed
        s3 = []
        s4 = parse_header
        while s4 != :failed
          s3 << s4
          s4 = parse_header
        end
        s4 = parse_moves
        if s4 != :failed
          s5 = []
          s6 = parse_fork
          while s6 != :failed
            s5 << s6
            s6 = parse_fork
          end
          @reported_pos = s0
          s0 = transform_root(s1, s2, s3, s4, s5)
        else
          @current_pos = s0
          s0 = :failed
        end
      else
        @current_pos = s0
        s0 = :failed
      end
      s0
    end
1079623
private void readRoot() throws IOException {
        if (root != null) {
            return;
        }
        final ByteArrayOutputStream content = new ByteArrayOutputStream();
        final byte[] buffer = new byte[READ_BUFFER_SIZE];
        try {
            while (trans_.read(buffer, 0, READ_BUFFER_SIZE) > 0) {
                content.write(buffer);
            }
        } catch (TTransportException e) {
            if (TTransportException.END_OF_FILE != e.getType()) {
                throw new IOException(e);
            }
        }
        root = OBJECT_MAPPER.readTree(content.toByteArray());
    }
925541
def get_tree_root(self):
        
        root = self
        while root.up is not None:
            root = root.up
        return root
1349414
def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'spTree'
          @shape_tree = ShapeTree.new(parent: self).parse(node_child)
        when 'bg'
          @background = Background.new(parent: self).parse(node_child)
        end
      end
      self
    end
135204
def traverse(self, predicate=lambda i, d: True,
                 prune=lambda i, d: False, depth=-1, branch_first=True,
                 visit_once=False, ignore_self=1):
        """"""
        return super(Tree, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self)
1278494
def branches(self):
        
        # We need to read the _cte_node_children attribute, so ensure it exists.
        self._ensure_parameters()
        return self.filter(
            **{"%s__id__in" % self.model._cte_node_children: self.all()}
        ).distinct()
686989
def tree(self):
        
        bs = self.model.branchScale
        for node in self._tree.find_clades():
            if node != self._tree.root:
                node.branch_length = self.t[self.name_to_nodeindex[node]] * bs
        return self._tree
1246193
def _get_substructure(self, treelist, pos):
        """"""
        subtree = None
        if len(pos) > 1:
            subtree = self._get_substructure(treelist[pos[0]][1], pos[1:])
        else:
            try:
                subtree = treelist[pos[0]]
            except (IndexError, TypeError):
                pass
        return subtree
354999
def leaf(self, parent, parts):
        
        name = splitPrefix(parts[-1])[1]
        if name.startswith('@'):
            result, path = parent.get_attribute(name[1:])
        else:
            result, ancestry = parent.get_child(name)
        if result is None:
            raise PathResolver.BadPath(name)
        return result
280525
def get_at(self, root_node, key):
        
        return self._get(root_node, bin_to_nibbles(to_string(key)))
604283
def get_xml_root_from_str(xml_str):
    """"""
    try:
        xml_root = etree.fromstring(xml_str.encode("utf-8"), NO_BLANKS_PARSER)
    # pylint: disable=broad-except
    except Exception as err:
        raise Dump2PolarionException("Failed to parse XML string: {}".format(err))
    return xml_root
765668
def parse_root
      @input += "\n" unless @input.end_with?("\n")

      s0 = @current_pos
      s1 = []
      s2 = parse_skipline
      while s2 != :failed
        s1 << s2
        s2 = parse_skipline
      end

      s2 = []
      s3 = parse_header
      while s3 != :failed
        s2 << s3
        s3 = parse_header
      end
      s3 = parse_initialboard
      s3 = nil if s3 == :failed
      s4 = []
      s5 = parse_header
      while s5 != :failed
        s4 << s5
        s5 = parse_header
      end
      parse_split
      s6 = parse_moves
      if s6 != :failed
        s7 = []
        s8 = parse_fork
        while s8 != :failed
          s7 << s8
          s8 = parse_fork
        end
        parse_nl
        @reported_pos = s0
        s0 = transform_root(s2, s3, s4, s6, s7)
      else
        @current_pos = s0
        s0 = :failed
      end

      s0
    end