Returns all layout objects of first level of depth
495724
def all(self):
        
        self._check_layout()
        return LayoutSlice(self.layout, slice(0, len(self.layout.fields), 1))
1228803
def get_descendants(self, include_self=False, depth=None):
        """"""
        params = {"%s__parent" % self._closure_childref():self.pk}
        if depth is not None:
            params["%s__depth__lte" % self._closure_childref()] = depth
        descendants = self._toplevel().objects.filter(**params)
        if not include_self:
            descendants = descendants.exclude(pk=self.pk)
        return descendants.order_by("%s__depth" % self._closure_childref())
318148
private function findInitialWrongDepthGap()
    {
        // get nodes where difference to parents depth > 1
        $qb = $this->accountRepository->createQueryBuilder('c2')
            ->select('count(c2.id) as results')
            ->join('c2.parent', 'c1')
            ->where('(c2.depth - 1) <> c1.depth');
        $depthGapResult = $qb->getQuery()->getSingleScalarResult();

        return $depthGapResult;
    }
1056542
def get_tree(cls, parent=None):
        
        if parent:
            depth = parent.get_depth() + 1
            results = [parent]
        else:
            depth = 1
            results = []
        cls._get_tree_recursively(results, parent, depth)
        return results
708170
def get_pages_for_display(self):
        """"""

        # Start with an empty queryset, and expand as needed
        all_pages = Page.objects.none()

        if self.max_levels == 1:
            # If no additional sub-levels are needed, return empty queryset
            return all_pages

        for item in self.top_level_items:

            if item.link_page_id:
                # Fetch a 'branch' of suitable descendants for this item and
                # add to 'all_pages'
                page_depth = item.link_page.depth
                if(
                    item.allow_subnav and
                    page_depth >= settings.SECTION_ROOT_DEPTH
                ):
                    all_pages = all_pages | Page.objects.filter(
                        depth__gt=page_depth,
                        depth__lt=page_depth + self.max_levels,
                        path__startswith=item.link_page.path)

        # Filter the entire queryset to include only pages suitable for display
        all_pages = all_pages & self.get_base_page_queryset()

        # Return 'specific' page instances if required
        if self.use_specific == constants.USE_SPECIFIC_ALWAYS:
            return all_pages.specific()

        return all_pages
63218
private View getNextView(RecyclerView parent) {
        View firstView = parent.getChildAt(0);

        // draw the first visible child's header at the top of the view
        int firstPosition = parent.getChildPosition(firstView);
        View firstHeader = getHeaderView(parent, firstPosition);

        for (int i = 0; i < parent.getChildCount(); i++) {

            View child = parent.getChildAt(i);
            RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();

            if (getOrientation(parent) == LinearLayoutManager.VERTICAL) {

                if (child.getTop() - layoutParams.topMargin > firstHeader.getHeight()) {
                    return child;
                }

            } else {

                if (child.getLeft() - layoutParams.leftMargin > firstHeader.getWidth()) {
                    return child;
                }

            }
        }
        return null;
    }
1013966
def at_depth(self, depth):
        

        for child in list(self.children):
            if depth == 0:
                yield child
            else:
                for grandchild in child.at_depth(depth - 1):
                    yield grandchild
582322
function deepFirstFindNav_(widget,groundId) {
  var compObj = widget.component;
  if (!compObj) return null;
  
  for (var sKey in compObj.$gui.compIdx) {
    var child = widget[sKey];
    var childObj = child && child.component;
    if (!childObj) continue;
    
    if (childObj.props['isNavigator.']) {
      var d = childObj.$gui.navItems;
      var ele = d && d[groundId];
      if (ele && ele.props['isPlayground.']) return child;
    }
    else {
      if (!childObj.props['childInline.']) {
        child = deepFirstFindNav_(child,groundId)
        if (child) return child;
      }
    }
  }
  
  return null;
}
808514
def _get_layout(self):
        
        connected = list()
        active_layout = list()
        disconnected = list()
        layout = OrderedDict(
            {"connected": OrderedDict(), "disconnected": OrderedDict()}
        )

        current = self.py3.command_output("xrandr")
        for line in current.splitlines():
            try:
                s = line.split(" ")
                infos = line[line.find("(") :]
                if s[1] == "connected":
                    output, state, mode = s[0], s[1], None
                    for index, x in enumerate(s[2:], 2):
                        if "x" in x and "+" in x:
                            mode = x
                            active_layout.append(output)
                            infos = line[line.find(s[index + 1]) :]
                            break
                        elif "(" in x:
                            break
                    connected.append(output)
                elif s[1] == "disconnected":
                    output, state, mode = s[0], s[1], None
                    disconnected.append(output)
                else:
                    continue
            except Exception as err:
                self.py3.log('xrandr error="{}"'.format(err))
            else:
                layout[state][output] = {"infos": infos, "mode": mode, "state": state}

        # initialize the active layout
        if self.active_layout is None:
            self.active_comb = tuple(active_layout)
            self.active_layout = self._get_string_and_set_width(
                tuple(active_layout), self.active_mode
            )

        return layout
808860
def depth_first_search (vis = DFSVisitor.new(self), &b)
      each_vertex do |u|
        unless vis.finished_vertex?(u)
          vis.handle_start_vertex(u)
          depth_first_visit(u, vis, &b)
        end
      end
    end
814853
def get_base_layout(figs):
	
	layout={}
	for fig in figs:
		if not isinstance(fig,dict):
			fig=fig.to_dict()
		for k,v in list(fig['layout'].items()):
			layout[k]=v
	return layout
153338
def get_all_child_edges(self):
        """"""
        all_child_edges = set()
        for parent in self.children:
            all_child_edges.add((parent.item_id, self.item_id))
            all_child_edges |= parent.get_all_child_edges()
        return all_child_edges
795093
private List<Tree<K, V>> findDepth(List<Tree<K, V>> zipper, int depth) {
        if (zipper.isEmpty())
            throw new RuntimeException("Defect: unexpected empty zipper while computing range");

        if (isBlackTree(zipper.get(0))) {
            return depth <= 1 ? zipper : findDepth(zipper.subList(1, zipper.size()), depth - 1);
        } else {
            return findDepth(zipper.subList(1, zipper.size()), depth);
        }
    }
1033011
def get_gos_d0d1(self):
        """"""
        return set([o.id for d in [0, 1] for o in self.gosubdag.rcntobj.depth2goobjs.get(d)])
429893
function depthFirst(node, parent) {
  var results = [];
  if (node && (typeof node === 'object')) {

    // valid node so push it to the list and set new parent
    //  don't overwrite parent if one was not given
    if ('type' in node) {
      if (parent !== undefined) {
        node.parent = parent;
      }
      parent = node;
      results.push(node);
    }

    // recurse object members using nested function call
    for (var key in node) {
      if (WHITE_LIST.test(key)) {
        var value = node[key];
        if (value && (typeof value === 'object')) {
          results.push.apply(results, depthFirst(value, parent));
        }
      }
    }
  }
  return results;
}
191301
function getAframeElementsFromSceneStructure(sceneStructure, parent) {
  var collection = parent ? null : [] // use collection or parent
  sceneStructure.forEach(function(element3d) {
    // check if type is supported in aframe
    if (validTypes.indexOf(element3d.type) > -1) {
      // get html attributes from element3d objects
      var el = addEntity({
        attributes: getAttributes(element3d),
        parent: parent
      })
      // the level scene might be baked
      if (element3d.type === 'level') {
        createBakedElement(el, element3d)
      }
      // recursively proceed through sceneStructure
      if (element3d.children && element3d.children.length) getAframeElementsFromSceneStructure(element3d.children, el)
      if (collection) collection.push(el)
    }
  })

  return collection
}
994382
def depth_first_visit (u, vis = DFSVisitor.new(self), &b)
      vis.color_map[u] = :GRAY
      vis.handle_examine_vertex(u)
      each_adjacent(u) { |v|
        vis.handle_examine_edge(u, v)
        if vis.follow_edge?(u, v)            # (u,v) is a tree edge
          vis.handle_tree_edge(u, v)         # also discovers v
          vis.color_map[v] = :GRAY           # color of v was :WHITE
          depth_first_visit(v, vis, &b)
        else                                 # (u,v) is a non tree edge
          if vis.color_map[v] == :GRAY
            vis.handle_back_edge(u, v)       # (u,v) has gray target
          else
            vis.handle_forward_edge(u, v)    # (u,v) is a cross or forward edge 
          end
        end
      }
      vis.color_map[u] = :BLACK
      vis.handle_finish_vertex(u)           # finish vertex
      b.call(u)
    end