def expand(dirs):
    """
    Expands four directions per CSS convention.

    `dirs` may be a four-element iterable of (top, right, bottom, left), or
    a two-element iterable of (top-bottom, left-right), or a single-element
    iterable or a plan value for all four directions.

    @return
      A `tuple` of top, right, bottom, left.
    """
    try:
        t, r, b, l = dirs
    except (TypeError, ValueError):
        pass
    else:
        return (t, r, b, l)
    try:
        tb, rl = dirs
    except (TypeError, ValueError):
        pass
    else:
        return (tb, rl, tb, rl)
    try:
        trbl, = dirs
    except (TypeError, ValueError):
        trbl = dirs
    return (trbl, trbl, trbl, trbl)