Find or create an evaluation result.

@param hierarchy Result hierarchy.
@param parent Parent result
@param name Long name
@param shortname Short name
@return Evaluation result
15665
public static EvaluationResult findOrCreate(ResultHierarchy hierarchy, Result parent, String name, String shortname) {
    ArrayList<EvaluationResult> ers = ResultUtil.filterResults(hierarchy, parent, EvaluationResult.class);
    EvaluationResult ev = null;
    for(EvaluationResult e : ers) {
      if(shortname.equals(e.getShortName())) {
        ev = e;
        break;
      }
    }
    if(ev == null) {
      ev = new EvaluationResult(name, shortname);
      hierarchy.add(parent, ev);
    }
    return ev;
  }
228299
private static boolean isWHQ(Tree t, Tree parent) {
    if (t == null) {
      return false;
    }
    boolean toReturn = false;
    if (t.value().startsWith("SQ")) {
      if (parent != null && parent.value().equals("SBARQ")) {
        Tree[] kids = parent.children();
        for (Tree kid : kids) {
          // looks for a WH.*
          if (kid.value().startsWith("WH")) {
            toReturn = true;
          }
        }
      }
    }

    if (DEBUG) {
      System.err.println("in isWH, decision: " + toReturn + " for node " + t);
    }

    return toReturn;
  }
913997
def display_hierarchy_helper(root, parent_id_to_children, depth):
  
  print '%s%s (%s)' % ('%s+--' % ('|'.join(['  '] * depth)),
                       root['name'], root['id'])

  # Recurse for each child of this root that has children.
  for child in parent_id_to_children.get(root['id'], []):
    display_hierarchy_helper(child, parent_id_to_children, depth + 1)
89056
public static Element[] getChildren( Element root, String name )
    {
        if( null == root )
        {
            return new Element[0];
        }
        NodeList list = root.getElementsByTagName( name );
        int n = list.getLength();
        ArrayList<Element> result = new ArrayList<Element>();
        for( int i = 0; i < n; i++ )
        {
            Node item = list.item( i );
            if( item instanceof Element )
            {
                result.add( (Element) item );
            }
        }
        Element[] retval = new Element[result.size()];
        result.toArray( retval );
        return retval;
    }
23896
private boolean createChild(Property sibling, String parentURI) {
        boolean skipped = sibling.getName().equals("children");

        if (!skipped) {
            //dump(sibling);
            String dataType = null;
            String uri = "";
            if (sibling.getValue().hasDefined("class-name")) {
                dataType = sibling.getValue().get("class-name").asString();
                uri = parentURI + "/" + sibling.getName();

                int idx = uri.indexOf(':');
                if (idx > 0) {
                    int idx2 = uri.lastIndexOf('/', idx);
                    if (idx2 >= 0 && (idx2 + 1) < uri.length())
                        uri = uri.substring(idx2 + 1);
                }
            }

            JndiEntry next = new JndiEntry(sibling.getName(), uri, dataType);
            if (sibling.getValue().hasDefined("value"))
                next.setValue(sibling.getValue().get("value").asString());

            stack.peek().getChildren().add(next);
            stack.push(next);
        }

        return skipped;
    }
258591
function(name) {
    name = name || '';

    var state = null;

    // Only use valid state queries
    if(!_validateStateName(name)) {
      return null;
    
    // Use cache if exists
    } else if(_stateCache[name]) {
      return _stateCache[name];
    }

    var nameChain = _getNameChain(name);
    var stateChain = nameChain
      .map(function(name, i) {
        var item = angular.copy(_stateLibrary[name]);
        return item;
      })
      .filter(function(parent) {
        return !!parent;
      });

    // Walk up checking inheritance
    for(var i=stateChain.length-1; i>=0; i--) {
      if(stateChain[i]) {
        var nextState = stateChain[i];
        state = angular.merge(nextState, state || {});
      }

      if(state && state.inherit === false) break;
    }

    // Store in cache
    _stateCache[name] = state;

    return state;
  }
341352
public void depthFirstSearch(Context context, SearchResultVisitor visitor, Resource root) {
        ArrayDeque<SearchResults.Result> stack = Queues.newArrayDeque();

        // Build an instance of a SearchResult for the root resource
        // but don't invoke the visitor with it
        boolean skipFirstVisit = true;
        SearchResults initialResults = new SearchResults();
        initialResults.addResult(root, new ArrayList<String>(0));
        stack.add(initialResults.iterator().next());

        while (!stack.isEmpty()) {
            SearchResults.Result r = stack.pop();
            if (skipFirstVisit) {
                skipFirstVisit = false;
            } else {
                if (!visitor.visit(r)) {
                    return;
                }
            }

            // Reverse the order of the results so we walk the left-most
            // branches first
            ImmutableList<SearchResults.Result> results = ImmutableList.copyOf(m_searcher.search(
                    context, matchKeyAndValue(Constants.PARENT_TERM_FIELD, r.getResource().getId())));
            for (SearchResults.Result result : results.reverse()) {
                stack.push(result);
            }
        }
    }
12047
private Xpp3Dom getChild(Xpp3Dom parentNode, String name) {
		Xpp3Dom child = parentNode.getChild(name);
		if (child != null) {
			return child;
		}
		
		return parentNode.getChild(namespace + name);
	}
741042
static public Element selectParentElement(Element element, String parentName) {
		Element parentElement = (Element) element.getParentNode();
		if (parentElement == null) {
			return null;
		}
		if (parentElement.getTagName().equals(parentName)) {
			return parentElement;
		}
		return selectParentElement(parentElement, parentName);
	}
248315
public static String evaluateName(final String _typeName,
                                      final String _name)
    {
        final StringBuilder ret = new StringBuilder();
        ret.append(_typeName).append(":").append(_name).toString();
        return ret.toString();
    }
133583
function lookup(name){
  utils.assertType(name, 'string', 'name');
  var node = this.lookup(name.val);
  if (!node) return nodes.null;
  return this.visit(node);
}
441734
@VisibleForTesting
  static Name simple(String name) {
    switch (name) {
      case ".":
        return SELF;
      case "..":
        return PARENT;
      default:
        return new Name(name, name);
    }
  }
771932
public FieldValue evaluate(FieldName name){
		Map<FieldName, FieldValue> values = getValues();

		FieldValue value = values.getOrDefault(name, EvaluationContext.UNDECLARED_VALUE);
		if(value != EvaluationContext.UNDECLARED_VALUE){
			return value;
		}

		return resolve(name);
	}
681135
public static <DH extends DraweeHierarchy> DraweeHolder<DH> create(
      @Nullable DH hierarchy,
      Context context) {
    DraweeHolder<DH> holder = new DraweeHolder<DH>(hierarchy);
    holder.registerWithContext(context);
    return holder;
  }
790986
public static Node getChildNode(Node parentNode, String name, String value){
                List<Node> matchingChildren = getChildren(parentNode, name, value);
                return (matchingChildren.size() > 0) ? matchingChildren.get(0) : null;
        }
88861
private static IIOMetadataNode getOrCreateChildNode(IIOMetadataNode parentNode, String name)
    {
        NodeList nodeList = parentNode.getElementsByTagName(name);
        if (nodeList.getLength() > 0)
        {
            return (IIOMetadataNode) nodeList.item(0);
        }
        IIOMetadataNode childNode = new IIOMetadataNode(name);
        parentNode.appendChild(childNode);
        return childNode;
    }
1205352
public Iterable<DContact> queryByLastName(Object parent, java.lang.String lastName) {
    return queryByField(parent, DContactMapper.Field.LASTNAME.getFieldName(), lastName);
  }