def METHOD_NAME(obj):
    from pathlib import Path
    from nipype.interfaces.base.specs import BaseTraitedSpec
    from nipype.interfaces.base.support import InterfaceResult
    paths = []
    stack = [obj]
    while len(stack) > 0:
        obj = stack.pop()
        if isinstance(obj, InterfaceResult):
            stack.append(obj.inputs)
            stack.append(obj.outputs)
        elif isinstance(obj, BaseTraitedSpec):
            stack.append(obj.get_traitsfree())
        elif hasattr(obj, "__dict__"):
            stack.append(obj.__dict__)
        elif isinstance(obj, dict):
            stack.extend(obj.values())
        elif isinstance(obj, str):
            if not obj.startswith("def") and Path(obj).exists():
                paths.append(obj)
        elif isinstance(obj, Path):
            if obj.exists():
                paths.append(obj)
        else:  # probably some kind of iterable
            try:
                stack.extend(obj)
            except TypeError:
                pass
    return paths