code: function(element, nodeName, scanDeep, warnNotFound) {
        var found = scanTree(element);
        if (!found && !!warnNotFound) {
          $log.warn($mdUtil.supplant("Unable to find node '{0}' in element '{1}'.",[nodeName, element[0].outerHTML]));
        }
  
        return angular.element(found || element);
  
        /**
         * Breadth-First tree scan for element with matching `nodeName`
         */
        function scanTree(element) {
          return scanLevel(element) || (scanDeep ? scanChildren(element) : null);
        }
  
        /**
         * Case-insensitive scan of current elements only (do not descend).
         */
        function scanLevel(element) {
          if (element) {
            for (var i = 0, len = element.length; i < len; i++) {
              if (element[i].nodeName.toLowerCase() === nodeName) {
                return element[i];
              }
            }
          }
          return null;
        }
  
        /**
         * Scan children of specified node
         */
        function scanChildren(element) {
          var found;
          if (element) {
            for (var i = 0, len = element.length; i < len; i++) {
              var target = element[i];
              if (!found) {
                for (var j = 0, numChild = target.childNodes.length; j < numChild; j++) {
                  found = found || scanTree([target.childNodes[j]]);
                }
              }
            }
          }
          return found;
        }
  
      }
docs: Functional equivalent for $element.filter(‘md-bottom-sheet’)
  useful with interimElements where the element and its container are important...
  
  @param {angular.JQLite} element to scan
  @param {string} nodeName of node to find (e.g. 'md-dialog')
  @param {boolean=} scanDeep optional flag to allow deep scans; defaults to 'false'.
  @param {boolean=} warnNotFound optional flag to enable log warnings; defaults to false