public static BaseWork getEnclosingWork(Operator<?> op, GenTezProcContext procCtx) {
    List<Operator<?>> ops = new ArrayList<Operator<?>>();
    findRoots(op, ops);
    for (Operator<?> r : ops) {
      BaseWork work = procCtx.rootToWorkMap.get(r);
      if (work != null) {
        return work;
      }
    }
    return null;
  }
getEncosingWork finds the BaseWork any given operator belongs to.
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java