PyElement (@NotNull final String className, @NotNull String memberName) { final PyElement result; //TODO: Get rid of this chain of copy pastes if (memberName.contains(".")) { result = findMethod(className, memberName.substring(1)); } else if (memberName.contains("#")) { result = findField(className, memberName.substring(1)); } else { result = findClass(memberName); } Assert.assertNotNull(String.format("No member %s found in class %s", memberName, className), result); return result; }