<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_or_create_node(self, level, entities, *args, **kwargs):
        ''' Retrieves a child Node based on the specified criteria, creating a
        new Node if necessary.

        Args:
            entities (dict): Dictionary of entities specifying which Node to
                return.
            args, kwargs: Optional positional or named arguments to pass onto
                class-specific initializers. These arguments are only used if
                a Node that matches the passed entities doesn't already exist,
                and a new one must be created.

        Returns:
            A Node instance.

        '''

        result = self.get_nodes(level, entities)

        if result:
            if len(result) > 1:
                raise ValueError("More than one matching Node found! If you're"
                                 " expecting more than one Node, use "
                                 "get_nodes() instead of get_or_create_node()."
                                 )
            return result[0]

        # Create Node
        if level == 'run':
            node = RunNode(entities, *args, **kwargs)
        else:
            node = Node(level, entities)

        entities = dict(entities, node_index=len(self.nodes), level=level)
        self.nodes.append(node)
        node_row = pd.Series(entities)
        self.index = self.index.append(node_row, ignore_index=True)

        return node