public static List<FieldNode> mergeFieldNodes(List<FieldNode> nodes, FieldNode fn) {
    List<FieldNode> result = new ArrayList<>(nodes);
    for (int i = 0; i < nodes.size(); ++i) {
      FieldNode mfn = mergeFieldNode(nodes.get(i), fn);
      if (mfn != null) {
        result.set(i, mfn);
        return result;
      }
    }
    result.add(fn);
    return result;
  }
Merge the field node 'fn' into list 'nodes', and return the result list.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/FieldNode.java