Finds the only path from the start node. If there is more than one,
        raises ValueError.
13225
def only_path(self):
        """"""
        start = [v for v in self.nodes if self.nodes[v].get('start', False)]
        if len(start) != 1: 
            raise ValueError("graph does not have exactly one start node")

        path = []
        [v] = start
        while True:
            path.append(v)
            u = v
            vs = self.edges.get(u, ())
            if len(vs) == 0:
                break
            elif len(vs) > 1:
                raise ValueError("graph does not have exactly one path")
            [v] = vs

        return path
31787
def find(self, path, all=False):
        '''
        
        '''
        found = os.path.join(settings.STATIC_ROOT, path)
        if all:
            return [found]
        else:
            return found
63434
def fast_relpath_optional(path, start):
  
  if len(start) == 0:
    # Empty prefix.
    return path

  # Determine where the matchable prefix ends.
  pref_end = len(start) - 1 if start[-1] == '/' else len(start)
  if pref_end > len(path):
    # The prefix is too long to match.
    return None
  elif path[:pref_end] == start[:pref_end] and (len(path) == pref_end or path[pref_end] == '/'):
    # The prefix matches, and the entries are either identical, or the suffix indicates that
    # the prefix is a directory.
    return path[pref_end+1:]
512394
def find_first(self, name=None, ns_uri=None):
        
        return self.find(name=name, ns_uri=ns_uri, first_only=True)
690842
def data_find(data, path):
    
    path_parts = path.split("/")
    try:
        sub_elm = [
            el
            for el in data
            if isinstance(el, (tuple, list)) and el[0] == path_parts[0]
        ][0]
    except IndexError:
        return None
    else:
        if len(path_parts) > 1:
            return data_find(sub_elm, "/".join(path_parts[1:]))
        return sub_elm
225190
def __nt_relpath(path, start=os.curdir):
    """"""

    if not path: raise ValueError("no path specified")

    start_list = os.path.abspath(start).split(os.sep)
    path_list = os.path.abspath(path).split(os.sep)
    if start_list[0].lower() != path_list[0].lower():
        unc_path, rest = os.path.splitunc(path)
        unc_start, rest = os.path.splitunc(start)
        if bool(unc_path) ^ bool(unc_start):
            raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)" \
                             % (path, start))
        else: raise ValueError("path is on drive %s, start on drive %s" \
                               % (path_list[0], start_list[0]))
    # Work out how much of the filepath is shared by start and path.
    for i in range(min(len(start_list), len(path_list))):
        if start_list[i].lower() != path_list[i].lower():
            break
        else: i += 1
        pass

    rel_list = [os.pardir] * (len(start_list)-i) + path_list[i:]
    if not rel_list: return os.curdir
    return os.path.join(*rel_list)
919671
def find(self, path):
        """"""
        path = path.split('.')
        node = self
        while node._parent:
            node = node._parent
        for name in path:
            node = node._tree.get(name, None)
            if node is None or type(node) is float:
                return None
        return node
1301145
function findNode(firstNode, predicate) {
    let curNode = firstNode;
    while (curNode != null) {
        if (predicate(curNode.value))
            return curNode;
        curNode = curNode.next;
    }
}
726043
def _walk_to_root(path, break_at=None):
    
    if not os.path.exists(path):  # pragma: no cover
        raise IOError("Starting path not found")

    if os.path.isfile(path):  # pragma: no cover
        path = os.path.dirname(path)

    last_dir = None
    current_dir = os.path.abspath(path)
    paths = []
    while last_dir != current_dir:
        paths.append(current_dir)
        paths.append(os.path.join(current_dir, "config"))
        if break_at and current_dir == os.path.abspath(break_at):  # noqa
            logger.debug("Reached the %s directory, breaking.", break_at)
            break
        parent_dir = os.path.abspath(os.path.join(current_dir, os.path.pardir))
        last_dir, current_dir = current_dir, parent_dir
    return paths
1077504
def find_one(self, **kwargs):
        
        kwargs["_limit"] = 1
        iterator = self.find(**kwargs)
        try:
            return next(iterator)
        except StopIteration:
            return None
1177059
def find_path(start, goal, neighbors_fnct, reversePath=False, heuristic_cost_estimate_fnct=lambda a, b: Infinite, distance_between_fnct=lambda a, b: 1.0, is_goal_reached_fnct=lambda a, b: a == b):
    """"""
    class FindPath(AStar):

        def heuristic_cost_estimate(self, current, goal):
            return heuristic_cost_estimate_fnct(current, goal)

        def distance_between(self, n1, n2):
            return distance_between_fnct(n1, n2)

        def neighbors(self, node):
            return neighbors_fnct(node)

        def is_goal_reached(self, current, goal):
            return is_goal_reached_fnct(current, goal)
    return FindPath().astar(start, goal, reversePath)
344211
def first( path_stack, node )
      #puts "#{depth}) Entering match( #{path.inspect}, #{tree.inspect} )"
      return nil if path.size == 0

      case path[0]
      when :document
        # do nothing 
        return first( path[1..-1], node )
      when :child
        #for c in node.children
        node.children.each do |c|
          #puts "#{depth}) CHILD checking #{name(c)}"
          r = first( path[1..-1], c )
          #puts "#{depth}) RETURNING #{r.inspect}" if r
          return r if r
        end
      when :qname
        name = path[2]
        #puts "#{depth}) QNAME #{name(tree)} == #{name} (path => #{path.size})"
        if node.name == name
          #puts "#{depth}) RETURNING #{tree.inspect}" if path.size == 3
          return node if path.size == 3
          return first( path[3..-1], node )
        else
          return nil
        end
      when :descendant_or_self
        r = first( path[1..-1], node )
        return r if r
        #for c in node.children
        node.children.each do |c|
          r = first( path, c )
          return r if r
        end
      when :node
        return first( path[1..-1], node )
      when :any
        return first( path[1..-1], node )
      end
      return nil
    end
237755
def in_single_path_and_inner(self):
        
        return len(self.successor) == 1 and self.successor[0] is not None and not self.successor[0].in_or_out and \
               len(self.precedence) == 1 and self.precedence[0] is not None and not self.successor[0].in_or_out
462383
def startswith(self, other):
        # type: (UrlPath) -> bool
        
        try:
            other = UrlPath.from_object(other)
        except ValueError:
            raise TypeError('startswith first arg must be UrlPath, str, PathParam, not {}'.format(type(other)))
        else:
            return self._nodes[:len(other._nodes)] == other._nodes
1315063
def multiple_paths_parser(value):
    
    if isinstance(value, six.string_types):
        value = value.split(os.path.pathsep)
    return value
722450
def find(self, name):
        
        for node in self.climb(whole=True):
            if node.name == name:
                return node
        return None
542023
def find(self, node, path):
        """"""

        return node.find(path, namespaces=self.namespaces)