Find the parent by a selector ref: http://stackoverflow.com/questions/14234560/javascript-how-to-get-parent-element-by-selector
@param {Array} config.sortable
502903
function(elm, selector) {
      var all, cur;

      all = document.querySelectorAll(selector);
      cur = elm.parentNode;

      while (cur && !hashedit.collectionHas(all, cur)) { //keep going up until you find a match
        cur = cur.parentNode; //go up
      }
      return cur; //will return null if not found
    }
58512
protected T getParentFromConfig() {
      //TODO: Move this to a converter
      String parentName = Config.get(canonicalName(), "parent").asString(null);
      if (parentName != null && DynamicEnum.isDefined(Cast.as(getClass()), parentName)) {
         return DynamicEnum.valueOf(Cast.as(getClass()), parentName);
      } else if (parentName != null) {
         try {
            parentName = parentName.replaceFirst(Pattern.quote(getClass().getCanonicalName()), "");
            DynamicEnum.register(Cast.as(Reflect.onClass(getClass()).invoke("create", parentName).get()));
         } catch (ReflectionException e) {
            return null;
         }
      }
      return null;
   }
231817
protected function _findInChildren(array $element, $id, $withParents, array &$parents)
    {
        if ($element['id'] == $id) {
            return $element;
        }
        foreach ($element['children'] as $child) {
            if ($child['id'] == $id) {
                if ($withParents) {
                    $parents[] = $element;
                }
                return $child;
            }
            if (null !== ($found = $this->_findInChildren($child, $id, $withParents, $parents))) {
                if ($withParents) {
                    $parents[] = $element;
                }
                return $found;
            }
        }
    }
393167
function searchParent(el, parentClass) {
    var found = false;
    var parentElement = el.parentNode;
    while (parentElement && found === false) {
      if (hasClass(parentElement, parentClass) === true) {
        found = true;
      } else {
        parentElement = parentElement.parentNode;
      }
    }
    if (found === true) {
      return parentElement.getAttribute('id');
    } else {
      return '';
    }
  }
781255
function(selector) {

	var allMatches = localnwt.all(selector),
		testNode = this._node,
		ancestor = null,
		maxDepth = 0;

	if( allMatches.size() == 0 ) {
		return null;
	}

	while( true ) {

		// Iterate through all matches for each parent, and exit as soon as we have a match
		// Pretty bad performance, but super small. TODO: Omtimize
		allMatches.each(function (el) {
			if (el._node == testNode) {
				ancestor = el;
			}
		});

		var parentNode = testNode.parentNode;

		if( ancestor || !parentNode) { break; }
		testNode = parentNode;
	}

	if( ancestor ) {
		return ancestor;
	} else {
		return null;
	}
}
386027
public static function findByName( $parentId, $parentType, $name, $config = [] ) {

		return self::queryByName( $parentId, $parentType, $name, $config )->all();
	}
412587
function select(parent, selectors) {
  if (parent === null || parent === undefined) {
    return null;
  }
  if (selectors.length === 0) {
    return parent;
  }
  let selector = selectors[0];
  return select(parent[selector], selectors.splice(1, selectors.length - 1));
}
520361
function getParent(type, id, parentType, root) {
		return _client.retrieve({
			type: type,
			id: id,
			properties: ['parent']
		})
		.then(function(obj) {
			
			if (obj.length > 0) {
				
				obj  = _.first(obj);
				type = _.get(obj, 'parent.type');
				id   = _.get(obj, 'parent.id');
				
				// if there is no parent type or id, the parent could not be found, throw an error
				if (!type || !id) {
					throw {
						errorCode: 404,
						message: 'could not find parent type'
					};
				}
				
				// if the parent is a match
				if (type === parentType) {
					
					// if a root search, keep looking for parent objects of the same type
					if (root === true) {
						return _client.retrieve({
							type: type,
							id: id,
							properties: ['parent']
						})
						.then(function(parent) {
							if (_.get(parent, 'parent.type') === parentType) {
								return getParent(type, id, parentType, root);
							}
							return {
								id: id,
								type: parentType
							};
						});
					}
					return {
						id: id,
						type: parentType
					};
				}
				
				return getParent(type, id, parentType, root);
			}
			
			throw {
				errorCode: 404,
				message: 'Object not found'
			};
		});
	}
369725
public static function queryByParentType( $parentType, $config = [] ) {

		$type	= isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
		$status	= isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;

		return self::find()->where( [ 'parentType' => $parentType, 'type' => $type, 'status' => $status ] );
	}
23236
function getParentSelector() {
  const type = NodeType.ParentSelectorType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  const content = '&';

  pos++;

  return newNode(type, content, line, column);
}
1166573
function checkParent( elem ) {
    // not needed if already has parent
    if ( elem.parentNode ) {
      return;
    }
    var fragment = document.createDocumentFragment();
    fragment.appendChild( elem );
  }
1036804
function getFixedParent (el) {
    let currentParent = el.offsetParent,
        parent;

    while (parent === undefined) {

        if (currentParent === null) {
            parent = null;
            break;
        }

        if (css(currentParent, 'position') !== 'fixed') {
            currentParent = currentParent.offsetParent;
        } else {
            parent = currentParent;
        }
    }

    return parent;
}
1104785
function _getOuterContainerParentOrSelf(el) {
    var /** @type {?} */ view = el.view;
    while (_isNgContainer(el, view)) {
        el = el.parent;
    }
    return el;
}
324230
function(selector)
	{
		var el = this.__obj;
		
		if (el)
		{
			var matchesFn;
			
			['matches','webkitMatchesSelector','mozMatchesSelector','msMatchesSelector','oMatchesSelector'].some(function(fn) 
			{
				if (typeof document.body[fn] == 'function') 
				{
					matchesFn = fn;
					return true;
				}
				
				return false;
			});
			
			var parent;
			
			// traverse parents
			while (el)
			{
				parent = el.parentElement;
				
				if (parent && parent[matchesFn](selector)) 
				{
					return parent;
				}
				
				el = parent;
			}
		}
	}
949159
function (selector, done) {
  this.evaluate_now((selector) => {
    let element = document.querySelector(selector)
    if (!element) {
      return null
    }

    for (let key in element) {
      if (key.startsWith('__reactInternalInstance$')) {
        const compInternals = element[key]._currentElement
        const compWrapper = compInternals._owner
        const {props, state, context} = compWrapper._instance
        return {
          props,
          state,
          context
        }
      }
    }

    return null
  }, done, selector)
}
1233142
public static function queryByParent( $parentId, $parentType, $config = [] ) {

		$ignoreSite	= isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;

		if( static::isMultiSite() && !$ignoreSite ) {

			$siteId	= isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

			return static::find()->where( 'parentId=:pid AND parentType=:ptype AND siteId=:siteId', [ ':pid' => $parentId, ':ptype' => $parentType, ':siteId' => $siteId ] );
		}
		else {

			return static::find()->where( 'parentId=:pid AND parentType=:ptype', [ ':pid' => $parentId, ':ptype' => $parentType ] );
		}
	}
1116889
function matchSelector(element, selector) {
        if (!element || element.nodeType !== 1) {
            return false
        }

        var parent,
            match,
            matchesSelector = element.webkitMatchesSelector || element.matchesSelector;

        if (matchesSelector) {
            match = matchesSelector.call(element, selector)
        } else {
            parent = element.parentNode;
            match = !! parent.querySelector(selector);
        }

        return match;
    }