def remove_expired_contacts(contact_graph, time):
    """Remove expired and thus obsolete contacts from the contact graphself.

    Helps reducing complexity and thus boost route finding performance.

    Args:
        contact_graph (ContactGraph): A ContactGraph object for topology
            information.
        time (type): The current time. All contacts that expired before that
            time will be removed.

    """
    graph_nodes = list(contact_graph.graph.keys())
    for node in graph_nodes:
        if node.to_time < time:
            contact_graph.remove_contact_node(node)
    del graph_nodes
