def restrictToHostsOnCurrentStage(statsboardData, hostsOnCurrentStage):
    """
    Removes data for hosts not on current stage from statsboardData, and
    returns the new version.

    :param statsboardData:
    :param hostsOnCurrentStage:
    :return:
    """

    # NOTE: can be optimized if necessary.
    newData = []
    for dataSlice in statsboardData:
        if "tags" in dataSlice:
            if "host" in dataSlice["tags"]:
                if dataSlice["tags"]["host"] in hostsOnCurrentStage:
                    newData.append(dataSlice)

    return newData