def expected_record(self, node):
        """
        Constructs the provenance record that would be saved in the given node
        if the pipeline was run on the current state of the repository

        Parameters
        ----------
        node : arcana.repository.tree.TreeNode
            A node of the Tree representation of the study data stored in the
            repository (i.e. a Session, Visit, Subject or Tree node)

        Returns
        -------
        expected_record : arcana.provenance.Record
            The record that would be produced if the pipeline is run over the
            study tree.
        """
        exp_inputs = {}
        # Get checksums/values of all inputs that would have been used in
        # previous runs of an equivalent pipeline to compare with that saved
        # in provenance to see if any have been updated.
        for inpt in self.inputs:  # @ReservedAssignment
            # Get iterators present in the input that aren't in this node
            # and need to be joined
            iterators_to_join = (self.iterators(inpt.frequency) -
                                 self.iterators(node.frequency))
            if not iterators_to_join:
                # No iterators to join so we can just extract the checksums
                # of the corresponding input
                exp_inputs[inpt.name] = inpt.collection.item(
                    node.subject_id, node.visit_id).checksums
            elif len(iterators_to_join) == 1:
                # Get list of checksums dicts for each node of the input
                # frequency that relates to the current node
                exp_inputs[inpt.name] = [
                    inpt.collection.item(n.subject_id, n.visit_id).checksums
                    for n in node.nodes(inpt.frequency)]
            else:
                # In the case where the node is the whole treee and the input
                # is per_seession, we need to create a list of lists to match
                # how the checksums are joined in the processor
                exp_inputs[inpt.name] = []
                for subj in node.subjects:
                    exp_inputs[inpt.name].append([
                        inpt.collection.item(s.subject_id,
                                             s.visit_id).checksums
                        for s in subj.sessions])
        # Get checksums/value for all outputs of the pipeline. We are assuming
        # that they exist here (otherwise they will be None)
        exp_outputs = {
            o.name: o.collection.item(node.subject_id, node.visit_id).checksums
            for o in self.outputs}
        exp_prov = copy(self.prov)
        if PY2:
            # Need to convert to unicode strings for Python 2
            exp_inputs = json.loads(json.dumps(exp_inputs))
            exp_outputs = json.loads(json.dumps(exp_outputs))
        exp_prov['inputs'] = exp_inputs
        exp_prov['outputs'] = exp_outputs
        exp_prov['joined_ids'] = self._joined_ids()
        return Record(
            self.name, node.frequency, node.subject_id, node.visit_id,
            self.study.name, exp_prov)
Constructs the provenance record that would be saved in the given node
        if the pipeline was run on the current state of the repository

        Parameters
        ----------
        node : arcana.repository.tree.TreeNode
            A node of the Tree representation of the study data stored in the
            repository (i.e. a Session, Visit, Subject or Tree node)

        Returns
        -------
        expected_record : arcana.provenance.Record
            The record that would be produced if the pipeline is run over the
            study tree.