<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_view_for_id(self, view_class, element_id, parent_item=None):
 """Searches and returns the View for the given id and type :param view_class: The view type to search for :param element_id: The id of element of the searched view :param gaphas.item.Item parent_item: Restrict the search to this parent item :return: The view for the given id or None if not found """

        from rafcon.gui.mygaphas.items.state import StateView
        from rafcon.gui.mygaphas.items.connection import DataFlowView, TransitionView
        if parent_item is None:
            items = self.get_all_items()
        else:
            items = self.get_children(parent_item)
        for item in items:
            if view_class is StateView and isinstance(item, StateView) and item.model.state.state_id == element_id:
                return item
            if view_class is TransitionView and isinstance(item, TransitionView) and \
                    item.model.transition.transition_id == element_id:
                return item
            if view_class is DataFlowView and isinstance(item, DataFlowView) and \
                    item.model.data_flow.data_flow_id == element_id:
                return item
        return None