/**
   * Collect all the content that should be recommended based on given user and radius
   *
   * @param position starting point to calculate recommendation
   * @param radiusU defines how many levels of users should be incorporated
   * @param radiusC defines how many levels of content should be incorporated
   */
  public Map<INode, IAttribute> recommend(INode position, int radiusU, int radiusC) {

    Map<INode, IAttribute> recommendation = new HashMap<INode, IAttribute>();

    // Find relevant User
    INode relUser = collectNode(position, radiusU);
    System.out.println("starting recommendation from user node: " + relUser.toString());

    // collect leaf content nodes from relUser content items
    Set<INode> userAttributes = relUser.getAttributeKeys();
    for (INode content : userAttributes) {

      Map<INode, IAttribute> contentLeafNodes = collectLeaves(content, null);
      for (INode leafNode : contentLeafNodes.keySet()) {
        recommendation.put(leafNode, contentLeafNodes.get(leafNode));
      }
    }

    return recommendation;
  }
  /**
   * Collect ratings of all content given by the input node
   *
   * @param position this is the starting point for collecting
   * @param inputNodeID this node defines the content that needs to be collected
   */
  public Map<Integer, IAttribute> collectRatings(
      INode position, INode testNode, Map<Integer, IAttribute> contentRatings) {

    // Create Map for content of test user with empty values if not existing
    if (contentRatings == null) {

      contentRatings = new HashMap<Integer, IAttribute>(); // DatasetID, AttributeData
      Set<INode> testContentKeys = testNode.getAttributeKeys();
      for (INode testContentKey : testContentKeys) {
        contentRatings.put((int) testContentKey.getDatasetId(), null);
      }
    }

    // Look for content nodes on the list and add it to collected ratings map
    Set<INode> posContentKeys = position.getAttributeKeys();
    Map<Integer, IAttribute> posContentMap = new HashMap<Integer, IAttribute>();
    for (INode posContentKey : posContentKeys) {

      // Find Dataset ID of Content Node -> FIXME: very inefficient
      int contentDatasetID = 0;
      for (Iterator<Entry<Integer, INode>> iter = leavesMapC.entrySet().iterator();
          iter.hasNext(); ) {
        Map.Entry<Integer, INode> e = (Map.Entry<Integer, INode>) iter.next();
        if (posContentKey.getId() == e.getValue().getId()) {
          contentDatasetID = e.getKey();
        }
      }

      posContentMap.put(contentDatasetID, position.getAttributeValue(posContentKey));
    }

    for (Entry<Integer, IAttribute> contentRating : contentRatings.entrySet()) {

      int datasetID = contentRating.getKey();
      IAttribute rating = contentRating.getValue();

      // Check if value still needs to be found
      if (rating == null) {

        try {
          IAttribute contentAttributes = posContentMap.get(datasetID);
          contentRatings.put(datasetID, posContentMap.get(datasetID));
        } catch (Exception e) {
          System.out.println(e);
        }
      }
    }

    // Check if all movies were found
    if (contentRatings.containsValue(null) != true) {
      return contentRatings;
    } else {

      // Go one level up if possible
      if (position.getParent() != null) {
        contentRatings = collectRatings(position.getParent(), testNode, contentRatings);
        if (contentRatings != null) {
          return contentRatings;
        }
      } else {
        return contentRatings;
      }
    }

    return null;
  }