code: public static int[] getParents(int n, VarConfig vc) {
          int[] parents = new int[n];
          Arrays.fill(parents, -2);
          for (Var v : vc.getVars()) {
              if (v instanceof LinkVar) {
                  LinkVar link = (LinkVar) v;
                  if (vc.getState(v) == LinkVar.TRUE) {
                      if (parents[link.getChild()] != -2) {
                          throw new IllegalStateException(
                                  "Multiple parents defined for the same child. Is this VarConfig for only one example?");
                      }
                      parents[link.getChild()] = link.getParent();
                  }
              }
          }
          return parents;
      }
docs: Extracts the parents as defined by a variable assignment for a single
  sentence.
  
  NOTE: This should NOT be used for decoding since a proper decoder will
  enforce the tree constraint.
  
  @param n The sentence length.
  @param vc The variable assignment.
  @return The parents array.