// Root returns command's ancestor
554231
func (cmd *Command) Root() *Command {
	ancestor := cmd
	for ancestor.parent != nil {
		ancestor = ancestor.parent
	}
	return ancestor
}
630503
func (m *GormAreaRepository) Root(ctx context.Context, spaceID uuid.UUID) (*Area, error) {
	defer goa.MeasureSince([]string{"goa", "db", "Area", "root"}, time.Now())
	var rootArea []Area

	rootArea, err := m.Query(FilterBySpaceID(spaceID), func(db *gorm.DB) *gorm.DB {
		return db.Where("space_id = ? AND nlevel(path)=1", spaceID)
	})

	if len(rootArea) != 1 {
		return nil, errors.NewInternalError(ctx, errs.Errorf("single Root area not found for space %s", spaceID))
	}
	if err != nil {
		return nil, err
	}
	return &rootArea[0], nil
}
885637
func (bldr *iisQueryBuilder) Ancestor(parentKey *datastore.Key) *iisQueryBuilder {
	bldr.q = bldr.q.Ancestor(parentKey)
	if bldr.plugin != nil {
		bldr.plugin.Ancestor(parentKey)
	}
	return bldr
}
944446
func (n *Node) getRootNode() *Node {
	if n.parent == nil {
		return n
	}
	return n.parent.getRootNode()
}
794443
func (a *AddBackDep) Root(c context.Context) *ds.Key {
	bdg, _ := a.Dep.Back(c)
	return ds.KeyForObj(c, bdg)
}
1136055
func (t *Tree) Root() (*File, error) {
	if !t.haveRaw {
		data, err := t.comp.scget(t.Score)
		if err != nil {
			return nil, err
		}
		if err := unpack(data, &t.raw); err != nil {
			return nil, err
		}
		t.haveRaw = true
	}

	dir := &File{
		t:   t,
		dir: &t.raw,
		n:   &nameNode{"/", node{IsTree: true}},
	}
	return dir, nil
}
485859
func (b *Builder) Parent() *Builder {
	if b.current == b.root {
		panic("root has no parent")
	}
	b.current = b.current.Parent
	return b
}
1073740
func main() {
	cmd.RootCmd.DisableAutoGenTag = true
	identity := func(s string) string {
		return fmt.Sprintf(`{{< relref "docs/%s" >}}`, s)
	}
	emptyStr := func(s string) string { return "" }
	doc.GenMarkdownTreeCustom(cmd.RootCmd, "./", emptyStr, identity)
}
495630
func (s *EnablePolicyTypeOutput) SetRoot(v *Root) *EnablePolicyTypeOutput {
	s.Root = v
	return s
}
646492
func (t *Tree) Root() []byte {
	// If the Tree is empty, return nil.
	if t.head == nil {
		return nil
	}

	// The root is formed by hashing together subTrees in order from least in
	// height to greatest in height. The taller subtree is the first subtree in
	// the join.
	current := t.head
	for current.next != nil {
		current = joinSubTrees(t.hash, current.next, current)
	}
	return current.sum
}
426916
func (s *server) Command(cmd string, args [][]byte) <-chan Result {

	if s.IsLeader() {
		cb := s.state.newCommand()
		cmdBytes := bytesForCommand(cb.originAddr, cb.reqNo, cmd, args)
		s.raft.Apply(cmdBytes, commandTimeout)
		return cb.result
	}
	// couldn't exec as leader, fallback to forwarding
	cb, err := s.dispatchToLeader(cmd, args)
	if err != nil {
		if cb != nil {
			cb.cancel()
		}
		ret := make(chan Result, 1)
		ret <- Result{nil, err}
		return ret
	}
	return cb.result
}
1155380
func (self *Tree) Root() *Node {
	if self.Nodes == nil {
		return nil
	} else {
		return &self.Levels[0][0]
	}
}
752064
func EnsureRoot(rootDir string) {
	if err := cmn.EnsureDir(rootDir, DefaultDirPerm); err != nil {
		cmn.PanicSanity(err.Error())
	}
	if err := cmn.EnsureDir(filepath.Join(rootDir, defaultConfigDir), DefaultDirPerm); err != nil {
		cmn.PanicSanity(err.Error())
	}
	if err := cmn.EnsureDir(filepath.Join(rootDir, defaultDataDir), DefaultDirPerm); err != nil {
		cmn.PanicSanity(err.Error())
	}

	configFilePath := filepath.Join(rootDir, defaultConfigFilePath)

	// Write default config file if missing.
	if !cmn.FileExists(configFilePath) {
		writeDefaultConfigFile(configFilePath)
	}
}
1226293
func (m *MemEngine) LookupRoot(_ context.Context) (Hash, error) {
	return m.root, nil
}
1304884
func chrootOrChdir(path string) error {
	if err := syscall.Chroot(path); err != nil {
		return fmt.Errorf("error chrooting to %q: %v", path, err)
	}
	if err := syscall.Chdir(string(os.PathSeparator)); err != nil {
		return fmt.Errorf("error changing to %q: %v", path, err)
	}
	return nil
}
36049
func Tree(cmd *Command, forest ...*CommandTree) *CommandTree {
	return &CommandTree{
		command: cmd,
		forest:  forest,
	}
}
1294464
func (p Path) Root() Path {
	if len(p) > 0 {
		return Path{p[0]}
	}
	return Path{uuid.Nil}
}