Given an array representing level-order traversal, rebuild the original tree structure. Use null for missing children and preserve the input array's positions, including trailing null values, when serializing the rebuilt tree for verification. Implement rebuild_tree(values), which accepts a list of integers or null values and returns the reconstructed tree serialized in the same level-order shape.
The input is a list values. Return a list containing the rebuilt tree's values in level-order, with null placeholders preserved.
def rebuild_tree(values):