def flatten_manifests(root_manifest, only_with_entries=False, recursion=0):
    """
    Convert a tree-structure Manifest into a flat list structured list of
    Manifests.
    :param root_manifest:
    :type root_manifest: Manifest
    :param only_with_entries: Switch to filter result to only those
    manifests with entries.
    :type only_with_entries: bool
    :param recursion: re-entry counter.
    :type recursion: int
    :return:
    :rtype: list
    """
    m_list = []
    if recursion >= 10:
        return m_list
    includes = root_manifest.includes
    entries = root_manifest.entries
    if only_with_entries:
        if entries is not None and len(entries) > 0:
            m_list.append(root_manifest)
    else:
        m_list.append(root_manifest)
    for i in includes:
        f = flatten_manifests(i, only_with_entries=only_with_entries,
                              recursion=recursion+1)
        m_list.extend(f)
    return m_list