/**
  * used for finding the top_level node of each module, given an containing node
  *
  * @param node
  * @return
  */
 public V getTopLevelNode(V node) {
   if (node.getType().getCategory() == NodeCategory.MODULE) return node;
   for (E e : this.getInEdges(node)) {
     if (e.isPartOf()) {
       return getTopLevelNode(this.getSource(e));
     }
   }
   return null;
 }
  /** used for getting the subgraph of a parent node (query, relation, view) */
  private List<V> subGraph(V node, List<V> subGraph) {

    for (E e : this.getOutEdges(node)) {
      // if edge is intramodule then add tonode
      if (e.isPartOf()) {
        if (!(subGraph.contains(this.getDest(e)))) {
          subGraph.add(this.getDest(e));
        }
        // call recursively for each adjacent node
        this.subGraph(this.getDest(e), subGraph);
      }
    }
    return subGraph;
  }
  /**
   * used for finding the policy of a node
   *
   * @param1 = event,
   * @param2 = Node receiving the message
   * @param3 = The previous prevailing policy
   */
  private PolicyType determinePolicy(
      EvolutionEvent<V> event, V nr, E edge, PolicyType previousPolicyType) {

    //  policy hierarchy
    // 1. query.condition, 2. query.attribute, 3. query, 4. relation.condition, 5.
    // relation.attribute, 6. relation
    //  search for policy towards the path

    System.out.println("determining policy for : " + nr.getName());
    // if edge is part of and child node has policy
    // then override parent's policy
    if (edge != null && edge.isPartOf()) {
      return previousPolicyType;
    }

    // if edge is dependency then get prevailing policy
    return getPrevailingPolicy(event, nr, previousPolicyType);
  }