'Browse the contents of a given directory path.
Returns a sequence of two-tuples ``(path, data)``.
If ``recursive`` is true, it returns results for all entries in the
given path.
If ``lookup`` is true and the ``path`` is to a track, the returned
``data`` is a future which will contain the results from looking up
the URI with :meth:`mopidy.core.LibraryController.lookup`. If
``lookup`` is false and the ``path`` is to a track, the returned
``data`` will be a :class:`mopidy.models.Ref` for the track.
For all entries that are not tracks, the returned ``data`` will be
:class:`None`.'

def browse(self, path, recursive=True, lookup=True):

    path_parts = re.findall(u'[^/]+', (path or u''))
    root_path = u'/'.join(([u''] + path_parts))
    uri = self._uri_map.uri_from_name(root_path)
    if (uri is None):
        for part in path_parts:
            for ref in self.core.library.browse(uri).get():
                if ((ref.type != ref.TRACK) and (ref.name == part)):
                    uri = ref.uri
                    break
            else:
                raise exceptions.MpdNoExistError(u'Not    found')
        root_path = self._uri_map.insert(root_path, uri)
    if recursive:
        (yield (root_path, None))
    path_and_futures = [(root_path, self.core.library.browse(uri))]
    while path_and_futures:
        (base_path, future) = path_and_futures.pop()
        for ref in future.get():
            path = u'/'.join([base_path, ref.name.replace(u'/', u'')])
            path = self._uri_map.insert(path, ref.uri)
            if (ref.type == ref.TRACK):
                if lookup:
                    (yield (path, self.core.library.lookup(uris=[ref.uri])))
                else:
                    (yield (path, ref))
            else:
                (yield (path, None))
                if recursive:
                    path_and_futures.append((path, self.core.library.browse(ref.uri)))
