File (@NotNull final String binaryPath) { final File binary = new File(binaryPath); final File parent = binary.getParentFile(); if (parent == null) return null; final File parent2 = parent.getParentFile(); if (parent2 == null) return null; final File parent3 = parent2.getParentFile(); if (parent3 != null && "envs".equals(parent3.getName())) { return parent2; } else if ("envs".equals(parent2.getName())) { return parent; } else { return null; } }