def _get_state_from_port(port,time_point):
    """
    Attempt to find a StateBlock-like object connected to a Port. If the
    object is indexed both in space and time, assume that the time index
    comes first.  If no components are assigned to the Port, raise a
    ValueError. If the first component's parent block has no index, raise an
    AttributeError. If different variables on the port appear to be connected
    to different state blocks, raise a RuntimeError.

    Args:
        port (pyomo.network.Port): a port with variables derived from some
            single StateBlock
        time_point : point in the time domain at which to index StateBlock
            (default = 0)

    Returns:
        (StateBlock-like) : an object containing all the components contained
            in the port.
    """
    vlist = list(port.iter_vars())
    states = [v.parent_block().parent_component() for v in vlist]

    if len(vlist) == 0:
        raise ValueError(
            f"No block could be retrieved from Port {port.name} "
            f"because it contains no components."
            )
    # Check the number of indices of the parent property block. If its indexed
    # both in space and time, keep the second, spatial index and throw out the
    # first, temporal index. If that ordering is changed, this method will
    # need to be changed as well.
    try:
        idx = vlist[0].parent_block().index()
    except AttributeError as err:
        raise AttributeError(
                f"No block could be retrieved from Port {port.name} "
                f"because block {vlist[0].parent_block().name} has no index."
                ) from err
    # Assuming the time index is always first and the spatial indices are all
    # the same
    if isinstance(idx,tuple):
        idx = (time_point,vlist[0].parent_block().index()[1:])

    else:
        idx = (time_point,)
    # This method also assumes that ports with different spatial indices won't
    # end up at the same port. Otherwise this check is insufficient.
    if all(states[0] is s for s in states):
        return states[0][idx]
    raise RuntimeError(
        f"No block could be retrieved from Port {port.name} "
        f"because components are derived from multiple blocks."
        )