private boolean hasSameBasePath(Dependency dependency1, Dependency dependency2) {
        if (dependency1 == null || dependency2 == null) {
            return false;
        }
        final File lFile = new File(dependency1.getFilePath());
        String left = lFile.getParent();
        final File rFile = new File(dependency2.getFilePath());
        String right = rFile.getParent();
        if (left == null) {
            return right == null;
        } else if (right == null) {
            return false;
        }
        if (left.equalsIgnoreCase(right)) {
            return true;
        }

        if (left.matches(".*[/\\\\](repository|local-repo)[/\\\\].*") && right.matches(".*[/\\\\](repository|local-repo)[/\\\\].*")) {
            left = getBaseRepoPath(left);
            right = getBaseRepoPath(right);
        }
        if (left.equalsIgnoreCase(right)) {
            return true;
        }
        //new code
        for (Dependency child : dependency2.getRelatedDependencies()) {
            if (hasSameBasePath(child, dependency1)) {
                return true;
            }
        }
        return false;
    }
private boolean hasSameBasePath ( Dependency dependency1 , Dependency dependency2 ) { if ( dependency1 == null || dependency2 == null ) { return false ; } final File lFile = new File ( dependency1 . getFilePath ( ) ) ; String left = lFile . getParent ( ) ; final File rFile = new File ( dependency2 . getFilePath ( ) ) ; String right = rFile . getParent ( ) ; if ( left == null ) { return right == null ; } else if ( right == null ) { return false ; } if ( left . equalsIgnoreCase ( right ) ) { return true ; } if ( left . matches ( ".*[/\\\\](repository|local-repo)[/\\\\].*" ) && right . matches ( ".*[/\\\\](repository|local-repo)[/\\\\].*" ) ) { left = getBaseRepoPath ( left ) ; right = getBaseRepoPath ( right ) ; } if ( left . equalsIgnoreCase ( right ) ) { return true ; } for ( Dependency child : dependency2 . getRelatedDependencies ( ) ) { if ( hasSameBasePath ( child , dependency1 ) ) { return true ; } } return false ; }
Determines if the two dependencies have the same base path.

@param dependency1 a Dependency object
@param dependency2 a Dependency object
@return true if the base paths of the dependencies are identical