The offset of *sub_category* in the overall sequence of leaf
        categories.
507525
def index(self, sub_category):
        
        index = self._parent.index(self)
        for this_sub_category in self._sub_categories:
            if sub_category is this_sub_category:
                return index
            index += this_sub_category.leaf_count
        raise ValueError('sub_category not in this category')
311884
def is_run_as_leaf(self, **kwargs):
        """"""
        # find the last subassistant_N
        i = 0
        while i < len(kwargs):  # len(kwargs) is maximum of subassistant_N keys
            if settings.SUBASSISTANT_N_STRING.format(i) in kwargs:
                leaf_name = kwargs[settings.SUBASSISTANT_N_STRING.format(i)]
            i += 1

        return self.name == leaf_name
355768
private void postTraversalProcessing() {
		int nc1 = treeSize;
		info[KR] = new int[leafCount];
		info[RKR] = new int[leafCount];

		int lc = leafCount;
		int i = 0;

		// compute left-most leaf descendants
		// go along the left-most path, remember each node and assign to it the path's
		// leaf
		// compute right-most leaf descendants (in reversed postorder)
		for (i = 0; i < treeSize; i++) {
			if (paths[LEFT][i] == -1) {
				info[POST2_LLD][i] = i;
			} else {
				info[POST2_LLD][i] = info[POST2_LLD][paths[LEFT][i]];
			}
			if (paths[RIGHT][i] == -1) {
				info[RPOST2_RLD][treeSize - 1 - info[POST2_PRE][i]] =
						(treeSize - 1 - info[POST2_PRE][i]);
			} else {
				info[RPOST2_RLD][treeSize - 1 - info[POST2_PRE][i]] =
						info[RPOST2_RLD][treeSize - 1
								- info[POST2_PRE][paths[RIGHT][i]]];
			}
		}

		// compute key root nodes
		// compute reversed key root nodes (in revrsed postorder)
		boolean[] visited = new boolean[nc1];
		boolean[] visitedR = new boolean[nc1];
		Arrays.fill(visited, false);
		int k = lc - 1;
		int kR = lc - 1;
		for (i = nc1 - 1; i >= 0; i--) {
			if (!visited[info[POST2_LLD][i]]) {
				info[KR][k] = i;
				visited[info[POST2_LLD][i]] = true;
				k--;
			}
			if (!visitedR[info[RPOST2_RLD][i]]) {
				info[RKR][kR] = i;
				visitedR[info[RPOST2_RLD][i]] = true;
				kR--;
			}
		}

		// compute minimal key roots for every subtree
		// compute minimal reversed key roots for every subtree (in reversed postorder)
		int parent = -1;
		int parentR = -1;
		for (i = 0; i < leafCount; i++) {
			parent = info[KR][i];
			while (parent > -1 && info[POST2_MIN_KR][parent] == -1) {
				info[POST2_MIN_KR][parent] = i;
				parent = info[POST2_PARENT][parent];
			}
			parentR = info[RKR][i];
			while (parentR > -1 && info[RPOST2_MIN_RKR][parentR] == -1) {
				info[RPOST2_MIN_RKR][parentR] = i;
				parentR =
						info[POST2_PARENT][info[RPOST2_POST][parentR]]; // get parent's postorder
				if (parentR > -1) {
					parentR = treeSize - 1 - info[POST2_PRE][parentR]; // if parent exists get its
					// rev. postorder
				}
			}
		}
	}
762837
def aux_moveTree(offset, tree):
	""""""
	if tree.x1 != None and tree.x2 != None :
		tree.x1, tree.x2 = tree.x1+offset, tree.x2+offset
		
	for c in tree.children:
		aux_moveTree(offset, c)
1002280
def _get_subtree_for(self, pos):
        """"""
        res = self._tree
        candidate = self._lookup_entry(self._tree, pos[:-1])
        if isinstance(candidate, Tree):
            res = candidate
        return res
101022
def leaves_not_empty(self):
        
        return [n for n in self.dfs if ((n.is_leaf) and (not n.is_empty))]
654105
def where_entry_category(query, category, recurse=False):
    

    category = str(category)
    if category and recurse:
        # We're recursing and aren't in /, so add the prefix clause
        return orm.select(
            e for e in query
            if e.category == category or e.category.startswith(category + '/')
        )

    if not recurse:
        # We're not recursing, so we need an exact match on a possibly-empty
        # category
        return orm.select(e for e in query if e.category == category)

    # We're recursing and have no category, which means we're doing nothing
    return query
810405
def _set_categories(self):
        
        for column, _ in self._categories.items():
            if column in self.columns:
                self[column] = self[column].astype('category')
1318483
def categories(self):
        
        r = [ch for ch in self._channels.values() if isinstance(ch, CategoryChannel)]
        r.sort(key=lambda c: (c.position, c.id))
        return r
461101
function () {
  var cats = getCategories();
  for (var i in cats) {
    log.debug('\n\nTEST CATEGORY: ' + cats[i]);
    testCategory(cats[i]);
  }
}
300675
def leaf_count(self):
        
        if not self._sub_categories:
            return 1
        return sum(category.leaf_count for category in self._sub_categories)
636011
public void subDivide() {
        northWest = new QuadTree(this, data, new Cell(boundary.getX() - .5 * boundary.getHw(),
                        boundary.getY() - .5 * boundary.getHh(), .5 * boundary.getHw(), .5 * boundary.getHh()));
        northEast = new QuadTree(this, data, new Cell(boundary.getX() + .5 * boundary.getHw(),
                        boundary.getY() - .5 * boundary.getHh(), .5 * boundary.getHw(), .5 * boundary.getHh()));
        southWest = new QuadTree(this, data, new Cell(boundary.getX() - .5 * boundary.getHw(),
                        boundary.getY() + .5 * boundary.getHh(), .5 * boundary.getHw(), .5 * boundary.getHh()));
        southEast = new QuadTree(this, data, new Cell(boundary.getX() + .5 * boundary.getHw(),
                        boundary.getY() + .5 * boundary.getHh(), .5 * boundary.getHw(), .5 * boundary.getHh()));

    }
559858
def verts_in_common(self, segments):
        
        verts_by_segm = self.verts_by_segm
        return sorted(reduce(lambda s0, s1: s0.intersection(s1),
                             [set(verts_by_segm[segm]) for segm in segments]))
1168226
function findLeaf(node, offset) {
          if (offset === undef) {
            offset = node.nodeType === 3 ? node.length : node.childNodes.length;
          }

          while (node && node.hasChildNodes()) {
            node = node.childNodes[offset];
            if (node) {
              offset = node.nodeType === 3 ? node.length : node.childNodes.length;
            }
          }
          return { node: node, offset: offset };
        }
463910
def sub_slots(x,match_fn,path=(),arr=None,match=False,recurse_into_matches=True):
  
  # todo: rename match to topmatch for clarity
  # todo: profiling suggests this getattr-heavy recursive process is the next bottleneck
  if arr is None: arr=[]
  if match and match_fn(x):
    arr.append(path)
    if not recurse_into_matches:
      return arr
  if isinstance(x, PathTree):
    for attr in x.ATTRS:
      val = getattr(x,attr)
      if attr in x.VARLEN:
        for i,elt in enumerate(val or ()):
          nextpath = path + ((attr,i),)
          sub_slots(elt,match_fn,nextpath,arr,True,recurse_into_matches)
      else:
        nextpath = path + (attr,)
        sub_slots(val,match_fn,nextpath,arr,True,recurse_into_matches)
  return arr
766647
def descendants(self):
        
        return self.members + \
            [submember for member in self.members for submember in member.descendants]
334126
def move_first_element_of_successor_to_child(child_index)
      child = @children[child_index]
      succ = @children[child_index + 1]

      if child.is_leaf?
        # Adjust offset for the successor node
        @offsets[child_index + 1] += 1
        # Move the value
        child.values << succ.values.shift
      else
        # Before:
        #
        # Root Node             +--------------------------------+
        # Offsets               | 0                            7 |
        # Children                |                            |
        #              child      v    succ                    v
        # Level 1    +---------------++-------------------------------------+
        # Offsets    | 0         4   ||    0         4          6         9 |
        # Children     |         |         |         |          |         |
        #              v         v         v         v          v         v
        # Leaves  +---------++-------++----------++-------++----------++-------+
        # Values  | A B C D || E F G || H I J K  || L  M  || N  O  P  || Q  R  |
        #
        # Index     0 1 2 3    4 5 6    7 8 9 10    11 12    13 14 15    16 17
        #
        # After:
        #
        # Root Node             +--------------------------------+
        # Offsets               | 0                           11 |
        # Children                |                            |
        #              child      v                succ        v
        # Level 1    +--------------------------++--------------------------+
        # Offsets    | 0         4         7    ||   0          2         5 |
        # Children     |         |         |         |          |         |
        #              v         v         v         v          v         v
        # Leaves  +---------++-------++----------++-------++----------++-------+
        # Values  | A B C D || E F G || H I J K  || L  M  || N  O  P  || Q  R  |
        #
        # Index     0 1 2 3    4 5 6    7 8 9 10    11 12    13 14 15    16 17
        #
        # Adjust the offsets of the successor. The 2nd original offset
        # determines the delta for the parent node.
        succ.offsets.shift
        delta = succ.offsets.first
        succ.offsets.map! { |o| o -= delta }
        # The additional child offset can be taken from the parent node
        # reference.
        child.offsets << @offsets[child_index + 1]
        # The parent node offset of the successor needs to be corrected by the
        # delta value.
        @offsets[child_index + 1] += delta
        # Move the child reference
        child.children << succ.children.shift
        child.children.last.parent = child
      end
    end