def union(root1, root2):
    """Perform a weighted union between root1 and root2.

    Args:
        root1 (Root): root of the first cluster in the union
        root2 (Root): root of the second cluster in the union

    Returns:
        NoneType or (Root, Root): If root1 and root2 are same, returns None;
            else, the big and small root node after the union.
    """
    if root1 != root2:
        # The equal case is important here, given the use in initialize_cluster_trees
        if root1.size >= root2.size:
            big_root = root1
            small_root = root2
        else:
            big_root = root2
            small_root = root1

        big_root.size += small_root.size

        if small_root.boundary:
            big_root.boundary = small_root.boundary

        big_root.parity = (big_root.parity + small_root.parity) % 2
        big_root.node.children.add(small_root.node)
        small_root.node.parent = big_root.node

        return big_root.node, small_root.node

    return None