def iterframe_master(obj):
    """try to return a frame iterator

    Parameters
    ----------
    obj : Trajectory or TrajectoryIterator or FrameIterator or a list of frames, or a list of
    Trajectory

    Examples
    --------
    >>> from pytraj import iterframe_master
    >>> # create frame itrator from a TrajectoryIterator
    >>> for frame in iterframe_master(traj): pass

    >>> # create frame itrator from a list of trajs
    >>> for frame in iterframe_master([traj, traj]): pass

    >>> # create frame iterator from a list of traj and frame
    >>> for frame in iterframe_master([traj, traj[0]]): pass

    >>> # create frame iterator from a list of frame iterator and chunk iterator
    >>> for frame in iterframe_master([traj.iterframe(), traj.iterchunk()]): pass
    """
    from pytraj import Frame
    from pytraj import FrameIterator
    if isinstance(obj, Frame):
        yield obj
    elif isinstance(obj, FrameIterator):
        for frame in obj:
            yield frame
    elif hasattr(obj, 'n_frames') and not isinstance(obj, Frame):
        for frame in obj:
            yield frame
    else:
        try:
            for traj_obj in obj:
                if isinstance(traj_obj, Frame):
                    yield traj_obj
                elif hasattr(traj_obj, '__name__'
                    ) and 'iterchunk' in traj_obj.__name__:
                    for _traj in traj_obj:
                        for frame in _traj:
                            yield frame
                else:
                    for frame in traj_obj:
                        yield frame
        except TypeError:
            raise TypeError('can not convert to Frame')
