code: def _validate_plan(plan):
      
      # Validate format of plan
      if not _validate_format(plan):
          return False
  
      # Verify no duplicate partitions
      partition_names = [
          (p_data['topic'], p_data['partition'])
          for p_data in plan['partitions']
      ]
      duplicate_partitions = [
          partition for partition, count in six.iteritems(Counter(partition_names))
          if count > 1
      ]
      if duplicate_partitions:
          _log.error(
              'Duplicate partitions in plan {p_list}'
              .format(p_list=duplicate_partitions),
          )
          return False
  
      # Verify no duplicate brokers in partition-replicas
      dup_replica_brokers = []
      for p_data in plan['partitions']:
          dup_replica_brokers = [
              broker
              for broker, count in Counter(p_data['replicas']).items()
              if count > 1
          ]
          if dup_replica_brokers:
              _log.error(
                  'Duplicate brokers: ({topic}, {p_id}) in replicas {replicas}'
                  .format(
                      topic=p_data['topic'],
                      p_id=p_data['partition'],
                      replicas=p_data['replicas'],
                  )
              )
              return False
  
      # Verify same replication-factor for every topic
      topic_replication_factor = {}
      for partition_info in plan['partitions']:
          topic = partition_info['topic']
          replication_factor = len(partition_info['replicas'])
          if topic in list(topic_replication_factor.keys()):
              if topic_replication_factor[topic] != replication_factor:
                  _log.error(
                      'Mismatch in replication-factor of partitions for topic '
                      '{topic}'.format(topic=topic),
                  )
                  return False
          else:
              topic_replication_factor[topic] = replication_factor
      return True
docs: Validate if given plan is valid based on kafka-cluster-assignment protocols.
  
      Validate following parameters:
      - Correct format of plan
      - Partition-list should be unique
      - Every partition of a topic should have same replication-factor
      - Replicas of a partition should have unique broker-set