public static boolean isMatchingTail(final Path pathToSearch, final Path pathTail) {
    Path tailPath = pathTail;
    String tailName;
    Path toSearch = pathToSearch;
    String toSearchName;
    boolean result = false;

    if (pathToSearch.depth() != pathTail.depth()) {
      return false;
    }

    do {
      tailName = tailPath.getName();
      if (tailName == null || tailName.isEmpty()) {
        result = true;
        break;
      }
      toSearchName = toSearch.getName();
      if (toSearchName == null || toSearchName.isEmpty()) {
        break;
      }
      // Move up a parent on each path for next go around. Path doesn't let us go off the end.
      tailPath = tailPath.getParent();
      toSearch = toSearch.getParent();
    } while (tailName.equals(toSearchName));
    return result;
  }
Compare path component of the Path URI; e.g. if hdfs://a/b/c and /a/b/c, it will compare the
'/a/b/c' part. If you passed in 'hdfs://a/b/c and b/c, it would return true. Does not consider
schema; i.e. if schemas different but path or subpath matches, the two will equate.
@param pathToSearch Path we will be trying to match.
@return True if <code>pathTail</code> is tail on the path of <code>pathToSearch</code>
hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java