code: def get_network_for_participant(self, participant):
          
          key = participant.id
          networks_with_space = (
              Network.query.filter_by(full=False).order_by(Network.id).all()
          )
          networks_participated_in = [
              node.network_id
              for node in Node.query.with_entities(Node.network_id)
              .filter_by(participant_id=participant.id)
              .all()
          ]
  
          legal_networks = [
              net for net in networks_with_space if net.id not in networks_participated_in
          ]
  
          if not legal_networks:
              self.log("No networks available, returning None", key)
              return None
  
          self.log(
              "{} networks out of {} available".format(
                  len(legal_networks), (self.practice_repeats + self.experiment_repeats)
              ),
              key,
          )
  
          legal_practice_networks = [
              net for net in legal_networks if net.role == "practice"
          ]
          if legal_practice_networks:
              chosen_network = legal_practice_networks[0]
              self.log(
                  "Practice networks available."
                  "Assigning participant to practice network {}.".format(
                      chosen_network.id
                  ),
                  key,
              )
          else:
              chosen_network = self.choose_network(legal_networks, participant)
              self.log(
                  "No practice networks available."
                  "Assigning participant to experiment network {}".format(
                      chosen_network.id
                  ),
                  key,
              )
          return chosen_network
docs: Find a network for a participant.
  
          If no networks are available, None will be returned. By default
          participants can participate only once in each network and participants
          first complete networks with `role="practice"` before doing all other
          networks in a random order.