def find_heuristic_path(graph, distances, start_node):
    """
    Given a graph, the corresponding distances matrix and a starting node,
    it finds the heuristic path that minimizes the total distance.

    Parameters
    ----------
    graph : a networkx.Graph object
        The graph containing clusters as nodes and labelled edges
        according to relative RMSD distances between pairs
    distances : a numpy.Array object
        The numpy array of shape (N, N), where N is the number of
        clustered molecules. It contains the RMSD value for each pair
        of clusters
    start_node : int
        The id of the node from which the path will be computed

    Returns
    -------
    dist : float
        The total distance of the final path
    path : list[int]
        The list of node ids that conform the final path
    """
    n = distances.shape[0]
    path = [start_node]
    dist = 0

    while len(path) < n:
        node = path[-1]
        new_neighbor = min(graph[node].items(), key=lambda x: x[1]["weight"])
        graph.remove_node(node)
        path.append(new_neighbor[0])
        dist += new_neighbor[1]['weight']

    dist += distances[path[-1], start_node]

    return dist, path