docs: def scale_meta_data_according_state(models_dict, rel_pos=None, as_template=False, fill_up=False):
      # TODO Documentation needed....
      """ Scale elements in dict to fit into dict state key element.
  
      If elements are already small enough no resize is performed.
      """
      # TODO check about positions of input-data- and output-data- or scoped variable-ports is needed
      # TODO adjustments of data ports positions are not sufficient -> origin state size is maybe needed for that
      # TODO consistency check on boundary and scale parameter for every if else case
  
      if 'states' in models_dict or 'scoped_variables' in models_dict:
          left, right, top, bottom = get_boundaries_of_elements_in_dict(models_dict=models_dict)
          parent_size = models_dict['state'].get_meta_data_editor()['size']
          margin, old_rel_pos, size = cal_frame_according_boundaries(left, right, top, bottom, parent_size, group=False)
          automatic_mode = True if rel_pos is None else False
          clearance = 0.2 if rel_pos is None else 0.
          rel_pos = (margin, margin) if rel_pos is None else rel_pos
          # rel_pos = (0., 0.) if fill_up else rel_pos
          clearance_scale = 1 + clearance
  
          assert parent_size[0] > rel_pos[0]
          assert parent_size[1] > rel_pos[1]
          # print("edges:", left, right, top, bottom)
          # print("margin:", margin, "rel_pos:", rel_pos, "old_rel_pos", old_rel_pos, "size:", size)
  
          parent_width, parent_height = parent_size
  
          boundary_width, boundary_height = size
          # print("parent width:   {0}, parent_height:   {1}".format(parent_width, parent_height))
          # print("boundary width: {0}, boundary_height: {1}".format(boundary_width, boundary_height))
  
          # no site scale
          if parent_width - rel_pos[0] > boundary_width * clearance_scale and \
                  parent_height - rel_pos[1] > boundary_height * clearance_scale and not fill_up:
              if automatic_mode:
                  resize_factor = 1.
                  boundary_width_in_parent = boundary_width*resize_factor
                  # print(boundary_width, resize_factor, boundary_width*resize_factor, boundary_height*resize_factor + margin*2, parent_height)
                  # print("left over width: ", parent_width - boundary_width_in_parent - rel_pos[0] - margin)
                  width_pos_offset_to_middle = (parent_width - boundary_width_in_parent - rel_pos[0] - margin)/2.
                  rel_pos = add_pos(rel_pos, (width_pos_offset_to_middle, 0.))
                  boundary_height_in_parent = boundary_height*resize_factor
                  # print("left over height: ", parent_height - boundary_height_in_parent - rel_pos[0] - margin)
                  height_pos_offset_to_middle = (parent_height - boundary_height_in_parent - rel_pos[1] - margin)/2.
                  rel_pos = add_pos(rel_pos, (0., height_pos_offset_to_middle))
              offset = subtract_pos((0., 0.), subtract_pos(old_rel_pos, rel_pos))
              offset_rel_pos_of_all_models_in_dict(models_dict, offset)
              return 1, 1  # (1, 1), offset, rel_pos
          # smallest site scale
          else:
              # increase of boundary or clearance results into bigger estimated size and finally stronger
              # reduction of original element sizes
              left, right, top, bottom = get_boundaries_of_elements_in_dict(models_dict=models_dict, clearance=clearance)
              parent_size = models_dict['state'].get_meta_data_editor()['size']
              margin, old_rel_pos, size = cal_frame_according_boundaries(left, right, top, bottom, parent_size, group=False)
  
              rel_pos = (margin, margin) if rel_pos is None else rel_pos
              assert parent_size[0] > rel_pos[0]
              assert parent_size[1] > rel_pos[1]
              # print("edges:", left, right, top, bottom)
              # print("margin:", margin, "rel_pos:", rel_pos, "old_rel_pos", old_rel_pos, "size:", size)
  
              parent_width, parent_height = parent_size
  
              boundary_width, boundary_height = size
              if (parent_height - rel_pos[1] - margin)/boundary_height < \
                      (parent_width - rel_pos[0] - margin)/boundary_width:
                  # print("#2"*20, 1, "#"*20, rel_pos)
                  resize_factor = (parent_height - rel_pos[1] - margin)/boundary_height
                  boundary_width_in_parent = boundary_width*resize_factor
                  # print(boundary_width, resize_factor, boundary_width*resize_factor)
                  # print("left over width: ", parent_width - boundary_width_in_parent - rel_pos[0] - margin)
                  width_pos_offset_to_middle = (parent_width - boundary_width_in_parent - rel_pos[0] - margin)/2.
                  rel_pos = add_pos(rel_pos, (width_pos_offset_to_middle, 0.))
                  # print(resize_factor, rel_pos)
              else:
                  # print("#2"*20, 2, "#"*20, rel_pos)
                  resize_factor = (parent_width - rel_pos[0] - margin)/boundary_width
                  boundary_height_in_parent = boundary_height*resize_factor
                  # print(boundary_width, resize_factor, boundary_width*resize_factor)
                  # print("left over height: ", parent_height - boundary_height_in_parent - rel_pos[0] - margin)
                  height_pos_offset_to_middle = (parent_height - boundary_height_in_parent - rel_pos[1] - margin)/2.
                  rel_pos = add_pos(rel_pos, (0., height_pos_offset_to_middle))
                  # print(resize_factor, rel_pos)
              frame = {'rel_pos': rel_pos, 'size': mult_two_vectors((resize_factor, resize_factor), size)}
              # print(models_dict['state'].get_meta_data_editor()['rel_pos'], \)
              #     parent_size, models_dict['state'].parent.get_meta_data_editor()['size']
              # print("frame", frame, resize_factor)
              # # rel_pos = mult_two_vectors((1, -1), frame['rel_pos'])
              offset = subtract_pos((0., 0.), old_rel_pos)
              offset_rel_pos_of_all_models_in_dict(models_dict, offset)
  
              resize_of_all_models_in_dict(models_dict, (resize_factor, resize_factor))
  
              offset_rel_pos_of_all_models_in_dict(models_dict, frame['rel_pos'])
              # scale_meta_data_according_frame(models_dict, frame)
              return resize_factor, resize_factor  # (resize_factor, resize_factor) , offset, frame['rel_pos']
      else:
          return 1, 1