builds path to an ancestor
342618
protected function buildPathToAncestor($lastAncestor)
    {
        $path = $this->buildPathToArea();
        foreach((array) $this->ancestors as $ancestor => $primaryKeyValues) {
            $path[] = $ancestor;
            if($ancestor != $lastAncestor) {
                $path[] = implode('|', array_values($primaryKeyValues));
            } else {
                $path[] = 'list';
                break;
            }
        }
        return $path;
    }
148943
def ancestors(self):
    
    ret = []
    workunit = self
    while workunit is not None:
      ret.append(workunit)
      workunit = workunit.parent
    return ret
574795
def path_upper(
        cls, object_id, limit_depth=1000000, db_session=None, *args, **kwargs
    ):
        
        tablename = cls.model.__table__.name
        raw_q = """
            WITH RECURSIVE subtree AS (
                    SELECT res.*, 1 as depth FROM {tablename} res
                    WHERE res.resource_id = :resource_id
                  UNION ALL
                    SELECT res_u.*, depth+1 as depth
                    FROM {tablename} res_u, subtree st
                    WHERE res_u.resource_id = st.parent_id
            )
            SELECT * FROM subtree WHERE depth<=:depth;
        """.format(
            tablename=tablename
        )
        db_session = get_db_session(db_session)
        q = (
            db_session.query(cls.model)
            .from_statement(sa.text(raw_q))
            .params(resource_id=object_id, depth=limit_depth)
        )
        return q
658397
def path(self):
        """"""
        yield self
        if not self.parent: return
        for node in self.parent.path: yield node
588523
def root_and_path(self):
        """"""
        rt = []
        curAttr = self
        while isinstance(curAttr.parent, AdHocTree):
            rt.append(curAttr.name)
            curAttr = curAttr.parent
        rt.reverse()
        return (curAttr.parent, rt)
93037
def _to_relative_path(self, path):
        """"""
        if not osp.isabs(path):
            return path
        if self.repo.bare:
            raise InvalidGitRepositoryError("require non-bare repository")
        if not path.startswith(self.repo.working_tree_dir):
            raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
        return os.path.relpath(path, self.repo.working_tree_dir)
247798
function _addRouteRecord(route, parent, exclude = false, ancestors = []) {
    const { path, name, handler } = route;
    const finalPath = _normalizePath(path, parent, ancestors);

    // Push path into ancestors array
    ancestors.push(path);

    const record = {
        name,
        parent,
        handler,
        path: finalPath,
        regex: PathToRegexp(finalPath),
        // redirect, TODO: Look into redirect functionality further
        before: route.before,
        init: route.init,
        update: route.update,
        after: route.after,
        unload: route.unload,
        pop: route.pop,
        meta: route.meta || {},
    };

    // Children should be mapped before parent in case of wildcard in parent
    if (route.children && route.children.length) {
        let i = 0;
        const length = route.children.length;

        for (; i < length; i++) {
            _addRouteRecord(route.children[i], route, exclude, ancestors);

            // After record is added, pop last ancestor off for the next set of paths
            ancestors.pop();
        }
    }

    // Exclude from main mapping/return created route record object
    if (exclude) {
        return record;
    }

    if (! pathMap[record.path]) {
        pathList.push(record.path);
        pathMap[record.path] = record;
    }

    if (name && ! nameMap[name]) {
        nameMap[name] = record;
    }
}
334278
def append_ancestor_entry(ancestors, ancestor, class_methods, instance_methods = nil)
      if class_methods || instance_methods
        ancestor_entry = {}
        ancestor_entry[:class] = class_methods if class_methods
        ancestor_entry[:instance] = instance_methods if instance_methods
        ancestors << {ancestor => ancestor_entry}
      end
    end
591900
def inheritance_lookup_path
      path = [self]
      until path.last == inheritable_root_controller
        path << path.last.superclass
      end
      path.collect(&:controller_path)
    end
1364681
private Path<?> buildPropertyPathForAnyType(Root<T> root, String stringPath) {
		
		// Si la racine est nulle
		if(root == null) return null;
		
		// Si la chaine est vide
		if(stringPath == null || stringPath.trim().length() == 0) return null;
		
		// Le Path à retournet
		Path<?> path = null;
		
		// On splitte sur le séparateur de champs
		String[] hierarchicalPaths = stringPath.trim().split("\\.");
		
		// Obtention du premier chemin
		path = root.get(hierarchicalPaths[0]);
		
		// Si la taille est > 1
		if(hierarchicalPaths.length > 1) {

			// Parcours
			for (int i = 1; i < hierarchicalPaths.length; i++) {
				
				// Le chemin
				String unitPath = hierarchicalPaths[i];
				
				// Si le path est vide ou est une suite d'espace
				if(unitPath == null || unitPath.trim().length() == 0) continue;
				
				// Acces à la ppt
				path = path.get(unitPath.trim());
			}
		}
		
		// On retourne le Path
		return path;
	}
1056353
def path(self, args, kw):
        """"""
        params = self._pop_params(args, kw)
        if args or kw:
            raise InvalidArgumentError("Extra parameters (%s, %s) when building path for %s" % (args, kw, self.template))
        return self.build_url(**params)
871356
function createPersistentPath(client, path, data, callback) {
  debug('createPersistentPath: "%s" "%s"', path, data);

  data = ensureBuffer(data);

  client.create(path, data, function(err) {
    if (err) {
      if (err.code !== NO_NODE)
        return callback(err);

      createParentPath(client, path, function(err) {
        if (err) return callback(err);

        client.create(path, data, callback);
      });
    } else
      callback(null, path);
  })
}
928962
function getDeepestCommonAncestorFrom(paths, filter) {
  // istanbul ignore next

  var _this = this;

  if (!paths.length) {
    return this;
  }

  if (paths.length === 1) {
    return paths[0];
  }

  // minimum depth of the tree so we know the highest node
  var minDepth = Infinity;

  // last common ancestor
  var lastCommonIndex, lastCommon;

  // get the ancestors of the path, breaking when the parent exceeds ourselves
  var ancestries = paths.map(function (path) {
    var ancestry = [];

    do {
      ancestry.unshift(path);
    } while ((path = path.parentPath) && path !== _this);

    // save min depth to avoid going too far in
    if (ancestry.length < minDepth) {
      minDepth = ancestry.length;
    }

    return ancestry;
  });

  // get the first ancestry so we have a seed to assess all other ancestries with
  var first = ancestries[0];

  // check ancestor equality
  depthLoop: for (var i = 0; i < minDepth; i++) {
    var shouldMatch = first[i];

    var _arr2 = ancestries;
    for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
      var ancestry = _arr2[_i2];
      if (ancestry[i] !== shouldMatch) {
        // we've hit a snag
        break depthLoop;
      }
    }

    // next iteration may break so store these so they can be returned
    lastCommonIndex = i;
    lastCommon = shouldMatch;
  }

  if (lastCommon) {
    if (filter) {
      return filter(lastCommon, lastCommonIndex, ancestries);
    } else {
      return lastCommon;
    }
  } else {
    throw new Error("Couldn't find intersection");
  }
}
260818
private ArchivePath getNestedPath(ArchivePath fullPath, ArchivePath basePath) {
        final String context = fullPath.get();
        final String baseContent = basePath.get();

        // Remove the base path from the full path
        String nestedArchiveContext = context.substring(baseContent.length());

        return new BasicPath(nestedArchiveContext);
    }
264534
function mergeLinked(source, target, pathArr, ancestorType) {
    var linked, type, res;

    if (pathArr.length) {
      // the external is referenced by the ancestor
      if (source.links && source.linked && source.links[ancestorType + "." + pathArr.join(".")]) {
        type = source.links[ancestorType + "." + pathArr.join(".")].type;
        linked = source.linked[type];
      }
    } else {
      // ancestor is the sought external
      type = ancestorType;
      linked = source[ancestorType] || [];
    }

    target.linked[type] = _.isArray(res = target.linked[type]) ? _.uniq(res.concat(linked), function(i){ return i.id}) : linked;
  }
509932
def ancestors(self, node):
        
        # We need to use the path virtual field, so ensure it exists.
        self._ensure_virtual_fields(node)
        return self.filter(pk__in=getattr(node, self.model._cte_node_path)[:-1])
1149095
def get_ancestor(ancestor_type)
      ancestor = self.parent_element
      target_type = {:directory => Directory,
                     :feature_file => FeatureFile,
                     :feature => Feature,
                     :test => TestElement,
                     :step => Step,
                     :table => Table,
                     :example => Example
      }[ancestor_type]

      raise(ArgumentError, "Unknown ancestor type '#{ancestor_type}'.") if target_type.nil?

      until ancestor.is_a?(target_type) || ancestor.nil?
        ancestor = ancestor.parent_element
      end

      ancestor
    end