class PartitionAccessor {

    private final Collection<RedisClusterNode> partitions;

    PartitionAccessor(Collection<RedisClusterNode> partitions) {
        this.partitions = partitions;
    }

    List<RedisClusterNode> getUpstream() {
        return get(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.UPSTREAM));
    }

    List<RedisClusterNode> getReadCandidates(RedisClusterNode upstream) {
        return get(redisClusterNode -> redisClusterNode.getNodeId().equals(upstream.getNodeId())
                || (redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)
                        && upstream.getNodeId().equals(redisClusterNode.getSlaveOf())));
    }

    List<RedisClusterNode> get(Predicate<RedisClusterNode> test) {<FILL_FUNCTION_BODY>}

}


        List<RedisClusterNode> result = new ArrayList<>(partitions.size());
        for (RedisClusterNode partition : partitions) {
            if (test.test(partition)) {
                result.add(partition);
            }
        }
        return result;
    
<no_super_class>