from typing import Union
from typing import List
import re


def get_path_segs(path: Union[str, None]) -> Union[List[str], None]:
    """
    Breaks a path string into its folders and filenames.
    Args:
        path: The path string or None.

    Returns: The path segments or None.

    """
    if path:
        # split on backslash or forward slash
        return list(filter(lambda x: len(x.strip()) > 0, [s for s in re.split(r"[\\/]", path)]))
    else:
        return None