def _lookup(self, p, directory, fsclass, create=1):
        if isinstance(p, Base):
            p.must_be_same(fsclass)
            return p
        p = str(p)
        if not os_sep_is_slash:
            p = p.replace(OS_SEP, '/')
        if p[0:1] == '
            p = p[1:]
            directory = self.Top
            if do_splitdrive:
                drive, p = _my_splitdrive(p)
                if drive:
                    root = self.get_root(drive)
                else:
                    root = directory.root
            else:
                root = directory.root
            p = p.strip('/')
            needs_normpath = needs_normpath_match(p)
            if p in ('', '.'):
                p = directory.get_labspath()
            else:
                p = directory.get_labspath() + '/' + p
        else:
            if do_splitdrive:
                drive, p = _my_splitdrive(p)
                if drive and not p:
                    p = '/'
            else:
                drive = ''
            if p != '/':
                p = p.rstrip('/')
            needs_normpath = needs_normpath_match(p)
            if p[0:1] == '/':
                root = self.get_root(drive)
            else:
                if directory:
                    if not isinstance(directory, Dir):
                        directory = self.Dir(directory)
                else:
                    directory = self._cwd
                if p in ('', '.'):
                    p = directory.get_labspath()
                else:
                    p = directory.get_labspath() + '/' + p
                if drive:
                    root = self.get_root(drive)
                else:
                    root = directory.root
        if needs_normpath is not None:
            ins = p.split('/')[1:]
            outs = []
            for d in ins:
                if d == '..':
                    try:
                        outs.pop()
                    except IndexError:
                        pass
                elif d not in ('', '.'):
                    outs.append(d)
            p = '/' + '/'.join(outs)
        return root._lookup_abs(p, fsclass, create)