from typing import Any
from pathlib import Path
from typing import Tuple


def lookup_path(context: Any, sub_paths: Path) -> Tuple[bool, Any]:
    """Lookup attributs in a context like dictionary.

    Arguments:
        context (Any): a dictionnary like structure with in and [] methods
            (support __contains__ or  (__iter__ and __getitem__)).
        sub_paths (Path): a path (single string or an ordered tuple of string)

    Returns:
        (Tuple[bool, Any]): (True, attribut value ) or (False, None) if path not found

    Exceptions:
        (RuntimeError): if context did not compliant

    """
    if not context:
        return (False, None)

    if not (hasattr(context, "__contains__") or (hasattr(context, "__iter__") and hasattr(context, "__getitem__"))):
        raise RuntimeError('Context must be dictionnary like')

    if isinstance(sub_paths, Tuple):
        if sub_paths:
            # len > 0
            current = context
            i = 0
            while i < len(sub_paths):
                p = sub_paths[i]
                if not current or p not in current:
                    return (False, None)
                i += 1
                current = current[p]
            return (True, current)
        return (False, None)

    # simple string
    match = sub_paths in context
    return (match, context[sub_paths] if match else None)