import json


def _format_node(node):
    """
    Prepares a node for insertion into the graph database. Dictionaries cannot
    be inserted.
    :param node: Node to format.
    :return: Formatted node.
    """
    formatted_node = dict()
    for prop in node:
        if isinstance(node[prop], dict) or isinstance(node[prop], list):
            formatted_node[prop] = json.dumps(node[prop])
        else:
            formatted_node[prop] = node[prop]
    return formatted_node