from typing import Sequence


def prepend_parts(prefix_parts: Sequence[str], parts: Sequence[str]) -> Sequence[str]:
    """
    Prepend `prefix_parts` before given `parts` (unless they are rooted).

    Both `parts` & `prefix_parts` must have been produced by :meth:`.json_path()`
    so that any root(``""``) must come first, and must not be empty
    (except `prefix-parts`).

    **Examples:**

        >>> prepend_parts(["prefix"], ["b"])
        ['prefix', 'b']

        >>> prepend_parts(("", "prefix"), ["b"])
        ['', 'prefix', 'b']
        >>> prepend_parts(["prefix ignored due to rooted"], ("", "b"))
        ('', 'b')

        >>> prepend_parts([], ["b"])
        ['b']
        >>> prepend_parts(["prefix irrelevant"], [])
        Traceback (most recent call last):
        IndexError: list index out of range
    """
    if "" != parts[0]:
        parts = [*prefix_parts, *parts]
    return parts