def _shorten_dir_split_path(path, sep):
    """Splits path into parts.

    Leading and repeated '/' chars are prepended to the
    part. E.g. "/foo/bar" is returned as ["/foo", "bar"] and
    "foo//bar" as ["foo", "/bar"].
    """
    if not path:
        return []
    parts = path.split(sep)
    packed = []
    blanks = []
    for part in parts:
        if part == '':
            blanks.append('')
        else:
            packed.append(sep.join(blanks + [part]))
            blanks = []
    if len(blanks) > 1:
        packed.append(sep.join(blanks))
    return packed
