def _should_cascade(members: CaseInsensitiveDict, replication: CaseInsensitiveDict, member: Member) -> bool:
        """Check whether *member* is supposed to cascade from another standby node.

        :param members: members that are eligible to stream (state=running and don't have nosync tag)
        :param replication: state of ``pg_stat_replication``, already filtered by member names from *members*
        :param member: member that we want to check

        :returns: ``True`` if provided member should stream from other standby node in
                  the cluster (according to ``replicatefrom`` tag), because some standbys
                  in a chain already streaming from the primary, otherwise ``False``
        """
        if not member.replicatefrom or member.replicatefrom not in members:
            return False

        member = members[member.replicatefrom]
        if not member.replicatefrom:
            return member.name in replication

        return _ReplicaList._should_cascade(members, replication, member)
Check whether *member* is supposed to cascade from another standby node.

        :param members: members that are eligible to stream (state=running and don't have nosync tag)
        :param replication: state of ``pg_stat_replication``, already filtered by member names from *members*
        :param member: member that we want to check

        :returns: ``True`` if provided member should stream from other standby node in
                  the cluster (according to ``replicatefrom`` tag), because some standbys
                  in a chain already streaming from the primary, otherwise ``False``
        
patroni/postgresql/sync.py